diff --git a/source/Annex_D_Example/uicc/test/example/uicc_example/Test_uicc_example.java b/source/Annex_D_Example/uicc/test/example/uicc_example/Test_uicc_example.java new file mode 100644 index 0000000000000000000000000000000000000000..eccd0655717436abafd485fb72d232bb1cd9b90f --- /dev/null +++ b/source/Annex_D_Example/uicc/test/example/uicc_example/Test_uicc_example.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.example.uicc_example; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_uicc_example extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/example/example/uicc_example"; + static final String CLASS_AID_1 = "A0000000 090002FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090002FF FFFFFF89 40010101"; + static final String CLASS_AID_2 = "A0000000 090002FF FFFFFF89 40020001"; + static final String APPLET_AID_2 = "A0000000 090002FF FFFFFF89 40020101"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_uicc_example() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, "8008" + + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("03010000 0102"); + + // test case 1: trigger applet1 + test.envelopeEventDownloadBrowserTermination(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1" + + "01CC"); + + // delete applet + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + + // test case 2: Applet 2 installation + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Fetch setUpMenu proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response + response = test.terminalResponse("81030121 00820282 81030100"); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_2); + result = response.checkData("10" + APPLET_AID_2" + + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userclass/UiccAPITestCardService.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userclass/UiccAPITestCardService.java new file mode 100644 index 0000000000000000000000000000000000000000..fa16fcb3469fd17a88fb9ad77433d67336af0c60 --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userclass/UiccAPITestCardService.java @@ -0,0 +1,29 @@ +/** + * @author SCP WG3, ETSI + * @version 0.01 + * UiccAPITestCardService defines method to get an object implementing interfaces + * This class has to be adapted to proprietary environment... + */ + +package org.etsi.scp.wg3.uicc.jcapi.userclass; + + + +public class UiccAPITestCardService { + + public static UiccAPITestCardService TestReference = null; + + /** + * static method to get a reference to UiccAPITestCardService + * @returns reference to the UiccAPITestCardService implementation class + */ + public static UiccAPITestCardService getTheUiccTestCardService() { + if (TestReference == null) { + return new UiccAPITestCardService(); + } + else { + return TestReference; + } + } + +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userclass/UiccTestModel.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userclass/UiccTestModel.java new file mode 100644 index 0000000000000000000000000000000000000000..4c3b89054e53c4d57ab9540e76e211025ad8b85d --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userclass/UiccTestModel.java @@ -0,0 +1,12 @@ +/** + * @author SCP WG3, ETSI + * @version 0.10 + * UiccTestModel defines mandatory common methods for all tests + */ +package org.etsi.scp.wg3.uicc.jcapi.userclass; + + +public abstract class UiccTestModel { + + public abstract boolean run(); +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/APDUResponse.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/APDUResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..2582d3b96a9a28a126477ecdfc4a217644457908 --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/APDUResponse.java @@ -0,0 +1,37 @@ +/** + * @author SCP WG3, ETSI + * @version 0.10 + * ResponseAPDU Class creates Object handling with APDU responses + */ +package org.etsi.scp.wg3.uicc.jcapi.userinterface; + + +public interface APDUResponse { + + /** + * Gives the Status Word returned by the card + * @return Status Word, as String + */ + public String getStatusWord(); + + /** + * Gives Data returned by the card + * @return Data, as String + */ + public String getData(); + + /** + * Check the received Status Word with expected Status Word + * @param expectedSw expected StatusWord, as String + * @return true or false, as boolean + */ + public boolean checkSw(String expectedSw); + + /** + * compare APDUResponse Object data with expected data + * @param expectedData, as String + * @return true or false, as boolean + */ + public boolean checkData(String expectedData); + +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccAdministrativeCommandsService.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccAdministrativeCommandsService.java new file mode 100644 index 0000000000000000000000000000000000000000..4fc8aee91551f5eba04141d384d8eca3e56cef50 --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccAdministrativeCommandsService.java @@ -0,0 +1,42 @@ +/** + * @author SCP WG3, ETSI + * @version 0.10 + * UiccAdministrativeCommandsService defines administrative methods from ETSI TS 102 222 specification + */ +package org.etsi.scp.wg3.uicc.jcapi.userinterface; + + +public interface UiccAdministrativeCommandsService { + + /** + * create a new file under the current DF or ADF, as described in TS 102 222. + * @param Value field of the File control parameters TLV, as String + * @param Logical Channel number, as String + * @return ResponseAPDU Object + */ + public APDUResponse createFile(String fcpValue); + public APDUResponse createFile(String logicalChannel, String fcpValue); + + + /** + * initiate the deletion of an EF immediately under the current DF, + * or a DF with its complete subtree, as described in TS 102 222. + * @param File Id, as String + * @param Logical Channel number, as String + * @return ResponseAPDU Object + */ + public APDUResponse deleteFile(String fileId); + public APDUResponse deleteFile(String logicalChannel, String fileId); + + /** + * resize a file under the current DF or ADF, as described in TS 102 222. + * If used with BER TLV file, mode 0 shall be used. + * @param File Id, as String + * @param New size, as String + * @param Logical Channel number, as String + * @return ResponseAPDU Object + */ + public APDUResponse resizeFile(String fileId, String size); + public APDUResponse resizeFile(String logicalChannel, String fileId, String size); + +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccApplicationManagementService.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccApplicationManagementService.java new file mode 100644 index 0000000000000000000000000000000000000000..232d935c755a05f16e9ceabdaa3d3c81f981f251 --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccApplicationManagementService.java @@ -0,0 +1,88 @@ +/** + * @author SCP WG3, ETSI + * @version 0.10 + * UiccApplicationManagementService defines methods to manage applications + */ +package org.etsi.scp.wg3.uicc.jcapi.userinterface; + + +public interface UiccApplicationManagementService { + + /** + * load cap file in the card + * @param relative path of the cap file, as String + * @return ResponseAPDU Object + */ + public APDUResponse loadPackage(String capFilePath); + + /** + * install and makeSelectable an instance in the card + * @param relative path of the cap file, as String + * @param Aid of the class, as String + * @param Aid of the instance, as String + * @param UICC System Specific TLV as defined in 102 226 specification, as String + * @return ResponseAPDU Object, corresponding to the GlobalPlatform command response. + */ + public APDUResponse installApplet(String capFilePath, String classAID, String appAID, String uiccSystemSpecificParameters); + + /** + * install an applet in installed state + * @param relative path of the cap file, as String + * @param AID of the class, as String + * @param AID of the instance, as String + * @param UICC System Specific TLV as defined in 102 226 specification, as String + * @return ResponseAPDU Object, corresponding to the GlobalPlatform command response. + */ + public APDUResponse installInstallApplet(String capFilePath, String classAID, String appAID, String uiccSystemSpecificParameters); + + /** + * make an applet selectable (install for make selectable) + * @param AID of the instance, as String + * @return ResponseAPDU Object, corresponding to the GlobalPlatform command response. + */ + public APDUResponse makeSelectableApplet(String appAID); + + /** + * perform a SelectApplication APDU command + * @param AID of instance, as String + * @param Logical Channel number, as String + * @return ResponseAPDU Object, containing the application response + */ + public APDUResponse selectApplication(String AID); + public APDUResponse selectApplication(String LogicalChannel, String AID); + + /** + * lock an application + * @param AID of application, as String + * @return ResponseAPDU Object, containing the application response + */ + public APDUResponse lockApplication(String appletAid); + + /** + * unlock an application + * @param AID of application, as String + * @return ResponseAPDU Object, containing the application response + */ + public APDUResponse unlockApplication(String appletAid); + + /** + * delete an applet specified by its AID + * @param AID of applet, as String + * @return ResponseAPDU Object + */ + public APDUResponse deleteApplet(String AID); + + /** + * delete a package specified by its path + * @param relative path of package, as String + * @return ResponseAPDU Object + */ + public APDUResponse deletePackage(String capFilePath); + + /** + * delete a package specified by its path, and all its related applications + * @param relative path of package, as String + * @return APDUResponse Object + */ + public APDUResponse deletePackageAndAllRelatedApplications(String capFilePath); +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccCardManagementService.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccCardManagementService.java new file mode 100644 index 0000000000000000000000000000000000000000..8a93f40237d352f704b7f77dd507fcef15b11199 --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccCardManagementService.java @@ -0,0 +1,235 @@ +/** + * @author SCP WG3, ETSI + * @version 0.10 + * UiccCardManagementService defines Toolkit methods, among them ETSI TS 102 221 specification + */ +package org.etsi.scp.wg3.uicc.jcapi.userinterface; + + +public interface UiccCardManagementService { + + static final String SW_OK = "9000"; // normal ending of the command + static final String DEFAULT_TERMINAL_PROFILE = "0901"; // Default Terminal Profile + public final static String BASIC_CHANNEL = "00"; + public final static String LOGICAL_CHANNEL_1 = "01"; + public final static String LOGICAL_CHANNEL_2 = "02"; + public final static String LOGICAL_CHANNEL_3 = "03"; + + public final static String APPLICATION_PIN_1 = "01"; + public final static String APPLICATION_PIN_2 = "02"; + public final static String APPLICATION_PIN_3 = "03"; + public final static String APPLICATION_PIN_4 = "04"; + public final static String APPLICATION_PIN_5 = "05"; + public final static String APPLICATION_PIN_6 = "06"; + public final static String APPLICATION_PIN_7 = "07"; + public final static String APPLICATION_PIN_8 = "08"; + public final static String ADM1 = "0A"; + public final static String ADM2 = "0B"; + public final static String ADM3 = "0C"; + public final static String ADM4 = "0D"; + public final static String ADM5 = "0E"; + public final static String LOCAL_PIN_1 = "81"; + public final static String LOCAL_PIN_2 = "82"; + public final static String LOCAL_PIN_3 = "83"; + public final static String LOCAL_PIN_4 = "84"; + public final static String LOCAL_PIN_5 = "85"; + public final static String LOCAL_PIN_6 = "86"; + public final static String LOCAL_PIN_7 = "87"; + public final static String LOCAL_PIN_8 = "88"; + public final static String ADM6 = "8A"; + public final static String ADM7 = "8B"; + public final static String ADM8 = "8C"; + public final static String ADM9 = "8D"; + public final static String ADM10 = "8E"; + + + /** + * resets and powers the card + * @return ATR, as String + */ + public String reset(); + + /** + * select a file + * @param File Id, as String + * @param Logical Channel number, as String + * @return FCP, as APDUResponse Object + */ + public APDUResponse selectFile(String FileId); + public APDUResponse selectFile(String LogicalChannel, String FileId); + + /** + * select an application for activation + * @param DFname, as String + * @param LogicalChannel number, as String + * @return FCP, as APDUResponse Object + */ + public APDUResponse selectForActivation(String DFname); + public APDUResponse selectForActivation(String LogicalChannel, String DFname); + + /** + * select an application for termination + * @param DFname, as String + * @param Logical Channel number, as String + * @return FCP, as APDUResponse Object + */ + public APDUResponse selectForTermination(String DFname); + public APDUResponse selectForTermination(String LogicalChannel, String DFname); + + /** + * activate a file + * @param file Id, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse activate(String FileId); + public APDUResponse activate(String LogicalChannel, String FileId); + + /** + * deactivate a file + * @param File Id, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse deactivate(String FileId); + public APDUResponse deactivate(String LogicalChannel, String FileId); + + /** + * open and close logical channels + * @param Operation Code (open/close logical channel), as String + * @param ChannelNb (0 to 3), as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse manageChannel(String OperationCode, String ChannelNb); + public APDUResponse manageChannel(String LogicalChannel, String OperationCode, String ChannelNb); + + /** + * send a status APDU + * @param Application Status P1 , as String + * @param Returned Data P2, as String + * @param Length of the expected data, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse status(String AppStatus, String ReturnedData, String DataLength); + public APDUResponse status(String LogicalChannel, String AppStatus, String ReturnedData, String DataLength); + + /** + * reads the data bytes of the current transparent EF + * @param offset, as short + * @param length to be read, as short + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse readBinary(String sfiOffset, String length); + public APDUResponse readBinary(String logicalChannel, String sfiOffset, String length); + + /** + * reads a record of the current linear fixed/cyclic EF + * @param record number, as short + * @param record offset, as short + * @param length to be read, as short + * @param mode for reading record + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse readRecord(String recordNb, String mode, String length); + public APDUResponse readRecord(String logicalChannel, String recordNb, String mode, String length); + + + /** + * updates the data bytes of the current transparent EF + * @param offset, as short + * @param length to be updated, as short + * @param source data to update, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse updateBinary(String sfiOffset, String data); + public APDUResponse updateBinary(String logicalChannel, String sfiOffset, String data); + + + /** + * updates the data bytes of the record of the current linear fixed/cyclic EF + * @param record number + * @param record offset, as short + * @param lenght to be updated, as short + * @param mode for updating record, as byte + * @param source data to update, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse updateRecord(String recordNb, String mode, String data); + public APDUResponse updateRecord(String logicalChannel, String recordNb, String mode, String data); + + /** + * increases the current record of the current cyclic EF + * @param increase value + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse increase(String incValue); + public APDUResponse increase(String logicalChannel, String incValue); + + /** + * verify a PIN key + * @param Key reference, as byte + * @param value of the PIN key, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse verifyPIN(String keyRef, String PINValue); + public APDUResponse verifyPIN(String logicalChannel, String keyRef, String PINValue); + + /** + * Change the value of a PIN key + * @param Key reference, as byte + * @param old value of the PIN key, as String + * @param new value of the PIN key, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse changePIN(String keyRef, String OldPINValue, String NewPINValue); + public APDUResponse changePIN(String logicalChannel, String keyRef, String OldPINValue, String NewPINValue); + + /** + * Enable a PIN key + * @param Key reference, as byte + * @param value of the PIN key, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse enablePIN(String keyRef, String PINValue); + public APDUResponse enablePIN(String logicalChannel, String keyRef, String PINValue); + + /** + * Disable a PIN key + * @param Key reference, as byte + * @param value of the PIN key, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse disablePIN(String keyRef, String PINValue); + public APDUResponse disablePIN(String logicalChannel, String keyRef, String PINValue); + + /** + * Unblock a PIN key + * @param Key reference, as byte + * @param unblock value of the PIN key, as String + * @param value of the PIN key, as String + * @param Logical Channel number, as String + * @return APDUResponse Object + */ + public APDUResponse unblockPIN(String keyRef, String unblockPINValue, String PINValue); + public APDUResponse unblockPIN(String logicalChannel, String keyRef, String unblockPINValue, String PINValue); + + + /** + * sends any kind of APDU command + * @param apdu command, as String + * @return APDUResponse Object + */ + public APDUResponse sendApdu(String apduCommand); + +} diff --git a/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccToolkitService.java b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccToolkitService.java new file mode 100644 index 0000000000000000000000000000000000000000..d0d411e4bc11b7b3a0b8021e64c61b1e9228c014 --- /dev/null +++ b/source/Annex_D_UiccInterfaces/org/etsi/scp/wg3/uicc/jcapi/userinterface/UiccToolkitService.java @@ -0,0 +1,212 @@ +/** + * @author SCP WG3, ETSI + * @version 0.10 + * UiccToolkitService defines Toolkit methods, among them ETSI TS 102 223 specification + */ +package org.etsi.scp.wg3.uicc.jcapi.userinterface; + + +public interface UiccToolkitService { + + /** + * perform Terminal Profile APDU command and all fetch/Terminal + * Response APDU until (90 00) status word + * @param Terminal Profile command parameters, as String + * @return APDUResponse Object + */ + public APDUResponse terminalProfileSession(String tpStr); + + /** + * perform a Terminal Profile APDU command + * @param Terminal Profile command parameters, as String + * @return APDUResponse Object + */ + public APDUResponse terminalProfile(String tpStr); + + /** + * perform a fetch APDU command + * @param length of expected data, as String + * @return APDUResponse Object + */ + public APDUResponse fetch(String expDataLength); + + /** + * perform a terminalResponse + * @param Terminal Response APDU Data, as String + * @return APDUResponse Object + */ + public APDUResponse terminalResponse(String cmd); + + /** + * perform an Envelope Menu Selection + * @param Item Identifier TLV, as String + * @param Help Request TLV, as String + * @return APDUResponse Object + * Send the following string : + * "D3 XX 82 02 01 81" + itemIdTLV + HelpRequestTLV + */ + public APDUResponse envelopeMenuSelection( + String itemIdTLV, // Item Identifier TLV + String HelpRequestTLV); // Help request TLV + + /** + * perform an Envelope Call Control by NAA + * @return APDUResponse Object + * Send the following string : + * "D4 11 82 02 82 81 86 02 81 01 93 07 81 F2 A3 34 05 76 67" + */ + public APDUResponse envelopeCallControlByNAA(); + + /** + * perform an Envelope Timer Expiration + * @param Timer Identifier TLV, as String + * @return APDUResponse Object + * Send the following string : + * "D7 0C 82 02 82 81" + TimerIdTLV + "25 03 00 00 00" + */ + public APDUResponse envelopeTimerExpiration( + String TimerIdTLV); // Timer Identifier TLV + + /** + * perform an Unrecognized Envelope + * @return APDUResponse Object + * Send the following string : + * "01 07 82 02 83 81 FF 01 01" + */ + public APDUResponse unrecognizedEnvelope(); + + /** + * perform an Envelope Event Download MT Call + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 00 82 02 83 81 9C 01 01" + */ + public APDUResponse envelopeEventDownloadMTCall(); + + /** + * perform an Envelope Event Download Call Connected + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 01 82 02 82 81 9C 01 01" + */ + public APDUResponse envelopeEventDownloadCallConnected(); + + /** + * perform an Envelope Event Download Call Disconnected + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 02 82 02 82 81 9C 01 01" + */ + public APDUResponse envelopeEventDownloadCallDisconnected(); + + /** + * perform an Envelope Event Download Location Status + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 03 82 02 82 81 1B 01 01" + */ + public APDUResponse envelopeEventDownloadLocationStatus(); + + /** + * perform an Envelope Event Download User Activity + * @return APDUResponse Object + * Send the following string : + * "D6 07 99 01 04 82 02 82 81" + */ + public APDUResponse envelopeEventDownloadUserActivity(); + + /** + * perform an Envelope Event Download Idle Screen Available + * @return APDUResponse Object + * Send the following string : + * "D6 07 99 01 05 82 02 02 81" + */ + public APDUResponse envelopeEventDownloadIdleScreenAvailable(); + + /** + * perform an Envelope Event Download Card Reader Status + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 06 82 02 82 81 20 01 FF" + */ + public APDUResponse envelopeEventDownloadCardReaderStatus(); + + /** + * perform an Envelope Event Download Language Selection + * @return APDUResponse Object + * Send the following string : + * "D6 0B 99 01 07 82 02 82 81 2D 02 46 52" + */ + public APDUResponse envelopeEventDownloadLanguageSelection(); + + /** + * perform an Envelope Event Download Browser Termination + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 08 82 02 82 81 34 01 00" + */ + public APDUResponse envelopeEventDownloadBrowserTermination(); + + /** + * perform an Envelope Event Download Data Available + * @param Channel Status TLV, as String + * @return APDUResponse Object + * Send the following string : + * "D6 0E 99 01 09 82 02 82 81" + ChannelStatusTLV + "37 01 0A" + */ + public APDUResponse envelopeEventDownloadDataAvailable( + String ChannelStatusTLV); // Channel Status TLV + + /** + * perform an Envelope Event Download Channel Status + * @param Channel Status TLV, as String + * @return APDUResponse Object + * Send the following string : + * "D6 0B 99 01 0A 82 02 82 81" + ChannelStatusTLV + */ + public APDUResponse envelopeEventDownloadChannelStatus( + String ChannelStatusTLV); // Channel Status TLV + + /** + * perform an Envelope Event Download Access Technology Change + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 0B 82 02 82 81 BF 01 00" + */ + public APDUResponse envelopeEventDownloadAccessTechnologyChange(); + + /** + * perform an Envelope Event Download Display Parameters Changed + * @return APDUResponse Object + * Send the following string : + * "D6 0C 99 01 0C 82 02 82 81 C0 03 10 10 01" + */ + public APDUResponse envelopeEventDownloadDisplayParametersChanged(); + + /** + * perform an Envelope Event Download Local Connection + * @param Service Record TLV, as String + * @return APDUResponse Object + * Send the following string : + * "D6 XX 99 01 0D 82 02 83 81" + ServiceRecordTLV + */ + public APDUResponse envelopeEventDownloadLocalConnection( + String ServiceRecordTLV); // Service Record TLV + + /** + * perform an Envelope Event Download Network Search Change Mode + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 0E 82 02 83 81 E5 01 00" + */ + public APDUResponse envelopeEventDownloadNetworkSearchModeChange(); + + /** + * perform an Envelope Event Download Browsing Status + * @return APDUResponse Object + * Send the following string : + * "D6 0A 99 01 0F 82 02 83 81 E4 01 00" + */ + public APDUResponse envelopeEventDownloadBrowsingStatus(); + +} diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/LoadUtil.java b/source/Annex_D_UiccTestUtil/uicc/test/util/LoadUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..96cbff7a8b7ab2d853d665c5d7cd8aaa7a3d7f71 --- /dev/null +++ b/source/Annex_D_UiccTestUtil/uicc/test/util/LoadUtil.java @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.util; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class LoadUtil extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/util"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public LoadUtil() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + + return (true); + } +} \ No newline at end of file diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/TestToolkitApplet.java b/source/Annex_D_UiccTestUtil/uicc/test/util/TestToolkitApplet.java new file mode 100644 index 0000000000000000000000000000000000000000..8e6ee273f5699b706facfe3e730f1434dc916997 --- /dev/null +++ b/source/Annex_D_UiccTestUtil/uicc/test/util/TestToolkitApplet.java @@ -0,0 +1,117 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.util; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; + +/** + * Definition of the super class of all the test applets. + * The result of each and every test case is stored in an array. + * The results of the test can be obtained by selecting the test applet : + * the applet ID and the test cases results are then returned in the response data. + */ +abstract public class TestToolkitApplet extends javacard.framework.Applet implements +ToolkitInterface, ToolkitConstants { + + /* + * Generic variables for all test applets + */ + /** version Java Card 2.2 version */ + private final static short VERSION = 0x0202; + + /** obReg ToolktRegistry object */ + protected ToolkitRegistry obReg; + + /** + * baTestAppletId byte array to store the identifier of the test applet, + * the first byte is the length of the AID. + */ + private byte[] baTestAppletId = new byte[17]; + + /** + * baTestsResults byte array containing the result of each and every test case, + * the first byte is the number of test cases. + */ + private byte[] baTestsResults = new byte[128]; + + + /** + * Constructor of the applet + */ + public TestToolkitApplet() { + } + + /** + * Method called by the sub classes to initialize the AID + */ + public void init() throws SystemException { + + // Register to the UICC Toolkit Registry. Shall be called after register() method invocation. + this.obReg = ToolkitRegistrySystem.getEntry(); + + if (JCSystem.getVersion() < TestToolkitApplet.VERSION) { + SystemException.throwIt((short)SystemException.ILLEGAL_VALUE); + } + // Get the AID value + this.baTestAppletId[0] = JCSystem.getAID().getBytes(this.baTestAppletId, (short)1); + Util.arrayFillNonAtomic(this.baTestsResults, (short)0, (short)this.baTestsResults.length, (byte)0x00); + } + + /** + * Method called by the Toolkit Framework + * + * @param clientAID the AID of the calling application + * @param parameter + */ + public Shareable getShareableInterfaceObject(AID clientAID, byte parameter) { + // According to CAT Runtime Environment behaviour for ToolkitInterface object retrieval + if ((clientAID == null) && (parameter == (byte)0x01)) { + return((Shareable) this); + } else { + return(null); + } + } + + /** + * Method called by the test applet to report the result of each test case + * + * @param testCaseNumber test case number + * @param result true if successful, false otherwise + */ + protected void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + this.baTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + this.baTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + this.baTestsResults[testCaseNumber] = (byte)0x00; + } + } + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + /* Construct and send the results of the tests */ + apdu.setOutgoing(); + apdu.setOutgoingLength((short)((short)(this.baTestAppletId[0] + this.baTestsResults[0]) + + (short)2)); + apdu.sendBytesLong(this.baTestAppletId, (short)0, (short)((short)(this.baTestAppletId[0]) + (short)1)); + apdu.sendBytesLong(this.baTestsResults, (short)0, (short)((short)(this.baTestsResults[0]) + (short)1)); + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } +} diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/TestToolkitApplet.opt b/source/Annex_D_UiccTestUtil/uicc/test/util/TestToolkitApplet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5bf6ad854f2e74f57c30aaeca593fb431736233c --- /dev/null +++ b/source/Annex_D_UiccTestUtil/uicc/test/util/TestToolkitApplet.opt @@ -0,0 +1,3 @@ +-exportpath ..\..\Export;.\ +-out EXP CAP JCA +uicc.test.util 0xA0:0x00:0x00:0x00:0x09:0x00:0x05:0xFF:0xFF:0xFF:0xFF:0x89:0xF0:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/UICCTestConstants.java b/source/Annex_D_UiccTestUtil/uicc/test/util/UICCTestConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..488fa44c9d38a73203bace59d5a6a6f98847bf1f --- /dev/null +++ b/source/Annex_D_UiccTestUtil/uicc/test/util/UICCTestConstants.java @@ -0,0 +1,118 @@ +package uicc.test.util; + +public class UICCTestConstants { + //MF + public final static short FID_MF = (short)0x3F00; + + // Reserved IDs + // These IDs are used to test that a DF/EF does not exist + // and are thus reserved. They shall not be used for perso. + public final static short FID_EF_RFU0 = (short)0x6F29; + public final static short FID_EF_RFU1 = (short)0x6F2A; + public final static short FID_EF_RFU2 = (short)0x6F2B; + + public final static short FID_DF_RFU1 = (short)0x5F01; + public final static short FID_DF_RFU2 = (short)0x5F02; + public final static short FID_DF_RFU3 = (short)0x5F03; + + // DF Ids + public final static short FID_DF_TEST = (short)0x7F4A; + public final static short FID_DF_SUB_TEST = (short)0x5F10; + + public final static short FID_DF_ADF2 = (short)0x7F4B; + + // File IDs + public final static short FID_EF_TNR = (short)0x6F01; + public final static short FID_EF_TNU = (short)0x6F02; + public final static short FID_EF_TARU = (short)0x6F03; + + public final static short FID_EF_CNR = (short)0x6F04; + public final static short FID_EF_CNU = (short)0x6F05; + public final static short FID_EF_CNIC = (short)0x6F1C; + public final static short FID_EF_CNDE = (short)0x6F07; + public final static short FID_EF_CNAC = (short)0x6F08; + public final static short FID_EF_CARU = (short)0x6F09; + + public final static short FID_EF_LNR = (short)0x6F0A; + public final static short FID_EF_LNU = (short)0x6F0B; + public final static short FID_EF_LARU = (short)0x6F0C; + + public final static short FID_EF_CINA = (short)0x6F0D; + + public final static short FID_EF_TRAC = (short)0x6F0E; + public final static short FID_EF_TDAC = (short)0x6F0F; + + public final static short FID_EF_CIAC = (short)0x6F10; + public final static short FID_EF_CIAA = (short)0x6F11; + public final static short FID_EF_CNRA = (short)0x6F12; + public final static short FID_EF_CUAC = (short)0x6F13; + + public final static short FID_EF_TAAC = (short)0x6F14; + + public final static short FID_EF_LADA = (short)0x6F15; + + public final static short FID_EF_TAAA = (short)0x6F16; + + public final static short FID_EF_LRUA = (short)0x6F17; + public final static short FID_EF_LUPC = (short)0x6F18; + + public final static short FID_EF_NOSH = (short)0x6F19; + + public final static short FID_EF_LSEA = (short)0x6F1A; + public final static short FID_EF_CSEA = (short)0x6F1B; + + public final static short FID_EF_TERM = (short)0x6F30; + public final static short FID_DF_TERM = (short)0x5F30; + + public final static short FID_EF_TAA = (short)0x4F10; + + public final static short FID_EF_LARR1 = (short)0x6FA1; + public final static short FID_EF_LARR2 = (short)0x6FA2; + public final static short FID_EF_LARR3 = (short)0x6FA3; + public final static short FID_EF_LARR4 = (short)0x6FA4; + public final static short FID_EF_LARR5 = (short)0x6FA5; + + public final static short FID_EF_TARR1 = (short)0x6FB1; + public final static short FID_EF_TARR2 = (short)0x6FB2; + public final static short FID_EF_TARR3 = (short)0x6FB3; + public final static short FID_EF_TARR4 = (short)0x6FB4; + public final static short FID_EF_TARR5 = (short)0x6FB5; + + public final static short FID_EF_CARR1 = (short)0x6FC1; + public final static short FID_EF_CARR2 = (short)0x6FC2; + public final static short FID_EF_CARR3 = (short)0x6FC3; + public final static short FID_EF_CARR4 = (short)0x6FC4; + public final static short FID_EF_CARR5 = (short)0x6FC5; + + public final static short FID_DF_ARR1 = (short)0x5F11; + public final static short FID_EF_TAR1T = (short)0x4F11; + + public final static short FID_DF_ARR2 = (short)0x5F12; + public final static short FID_EF_TAR2T = (short)0x4F12; + + public final static short FID_DF_ARR3 = (short)0x5F13; + public final static short FID_EF_TAR3T = (short)0x4F13; + + public final static short FID_DF_ARR4 = (short)0x5F14; + public final static short FID_EF_TAR4T = (short)0x4F14; + + public final static short FID_DF_ARR5 = (short)0x5F15; + public final static short FID_EF_TAR5T = (short)0x4F15; + + public final static short FID_EF_ARR_MF = (short)0x2F06; + public final static short FID_EF_ARR_ADF = (short)0x6F06; + + public final static short FID_EF_UICC = (short)0x2FE4; + + public final static short FID_ADF = (short)0x7FFF; + + public final byte[] AID_ADF1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, + (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + + public final byte[] AID_ADF2 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, + (byte)0xD0, (byte)0x00, (byte)0x00, (byte)0x02}; +} diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.cap b/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.cap new file mode 100644 index 0000000000000000000000000000000000000000..15588c1eef6005a13e8bbb40e395670dcfc07066 Binary files /dev/null and b/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.cap differ diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.exp b/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.exp new file mode 100644 index 0000000000000000000000000000000000000000..f12edda18bfd00e4def8db7b4e1b197af3418dde Binary files /dev/null and b/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.exp differ diff --git a/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.jca b/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.jca new file mode 100644 index 0000000000000000000000000000000000000000..a3061682cc6e31e4975f939ad2eb45cc7cffb7ff --- /dev/null +++ b/source/Annex_D_UiccTestUtil/uicc/test/util/javacard/util.jca @@ -0,0 +1,466 @@ +// converted by version 1.3 +// on Wed Sep 27 10:19:00 CEST 2006 + +.package uicc/test/util { + .aid 0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0xF0:0x0:0x0:0x0; + .version 1.0; + + .imports { + 0xA0:0x0:0x0:0x0:0x62:0x1:0x1 1.2; //javacard/framework + 0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x12:0x0:0x0:0x0 1.0; //uicc/toolkit + 0xA0:0x0:0x0:0x0:0x62:0x0:0x1 1.0; //java/lang + } + + .constantPool { + // 0 + instanceFieldRef byte[] TestToolkitApplet/baTestAppletId; + // 1 + instanceFieldRef byte[] TestToolkitApplet/baTestsResults; + // 2 + instanceFieldRef 1.9 TestToolkitApplet/obReg; + // 3 + instanceFieldRef byte[] UICCTestConstants/AID_ADF1; + // 4 + instanceFieldRef byte[] UICCTestConstants/AID_ADF2; + // 5 + staticMethodRef 0.8.9()S; // javacard/framework/JCSystem.getVersion()S + // 6 + staticMethodRef 0.13.1(S)V; // javacard/framework/SystemException.throwIt(S)V + // 7 + staticMethodRef 0.8.3()Ljavacard/framework/AID;; // javacard/framework/JCSystem.getAID()Ljavacard/framework/AID; + .descriptor Ljavacard/framework/AID; 0.6; + + // 8 + virtualMethodRef 0.6.3([BS)B; // javacard/framework/AID.getBytes([BS)B + // 9 + staticMethodRef 0.16.3([BSSB)S; // javacard/framework/Util.arrayFillNonAtomic([BSSB)S + // 10 + virtualMethodRef 0.3.3()Z; // javacard/framework/Applet.selectingApplet()Z + // 11 + virtualMethodRef 0.10.7()S; // javacard/framework/APDU.setOutgoing()S + // 12 + virtualMethodRef 0.10.9(S)V; // javacard/framework/APDU.setOutgoingLength(S)V + // 13 + virtualMethodRef 0.10.5([BSS)V; // javacard/framework/APDU.sendBytesLong([BSS)V + // 14 + staticMethodRef 0.7.1(S)V; // javacard/framework/ISOException.throwIt(S)V + // 15 + staticMethodRef 2.0.0()V; // java/lang/Object.()V + // 16 + staticMethodRef 1.16.0()Luicc/toolkit/ToolkitRegistry;; // uicc/toolkit/ToolkitRegistrySystem.getEntry()Luicc/toolkit/ToolkitRegistry; + .descriptor Luicc/toolkit/ToolkitRegistry; 1.9; + + // 17 + staticMethodRef 0.3.0()V; // javacard/framework/Applet.()V + } + + .class public abstract TestToolkitApplet 0 extends 0.3 { // extends javacard/framework/Applet + + .shareable; + + .fields { + protected 1.9 obReg 0; // Luicc/toolkit/ToolkitRegistry; + private byte[] baTestAppletId 1; // [B + private byte[] baTestsResults 2; // [B + private static final short VERSION = 514; // S + } + + .publicMethodTable 5 { + equals(Ljava/lang/Object;)Z; + register()V; + register([BSB)V; + selectingApplet()Z; + deselect()V; + getShareableInterfaceObject(Ljavacard/framework/AID;B)Ljavacard/framework/Shareable;; + select()Z; + process(Ljavacard/framework/APDU;)V; + init()V; + reportTestOutcome(BZ)V; + processToolkit(S)V; + } + + .packageMethodTable 0 { + } + + .implementedInterfaceInfoTable { + .interface 0.2 { // javacard/framework/Shareable + } + + .interface 1.8 { // uicc/toolkit/ToolkitInterface + 10; // processToolkit(S)V + } + + .interface 1.7 { // uicc/toolkit/ToolkitConstants + } + + } + + .method public ()V 0 { + .stack 2; + .locals 0; + + L0: aload_0; + invokespecial 17; // javacard/framework/Applet.()V + aload_0; + bspush 17; + newarray 11; + putfield_a 0; // reference uicc/test/util/TestToolkitApplet.baTestAppletId + aload_0; + sspush 128; + newarray 11; + putfield_a 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + return; + } + + .method public init()V 8 { + .stack 5; + .locals 0; + + L0: aload_0; + invokestatic 16; // uicc/toolkit/ToolkitRegistrySystem.getEntry()Luicc/toolkit/ToolkitRegistry; + putfield_a 2; // reference uicc/test/util/TestToolkitApplet.obReg + invokestatic 5; // javacard/framework/JCSystem.getVersion()S + sspush 514; + if_scmpge L2; + L1: sconst_1; + invokestatic 6; // javacard/framework/SystemException.throwIt(S)V + L2: getfield_a_this 0; // reference uicc/test/util/TestToolkitApplet.baTestAppletId + sconst_0; + invokestatic 7; // javacard/framework/JCSystem.getAID()Ljavacard/framework/AID; + getfield_a_this 0; // reference uicc/test/util/TestToolkitApplet.baTestAppletId + sconst_1; + invokevirtual 8; // javacard/framework/AID.getBytes([BS)B + bastore; + getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sconst_0; + getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + arraylength; + sconst_0; + invokestatic 9; // javacard/framework/Util.arrayFillNonAtomic([BSSB)S + pop; + return; + } + + .method public getShareableInterfaceObject(Ljavacard/framework/AID;B)Ljavacard/framework/Shareable; 5 { + .stack 2; + .locals 0; + + .descriptor Ljavacard/framework/AID; 0.6; + .descriptor Ljavacard/framework/Shareable; 0.2; + + L0: aload_1; + ifnonnull L3; + L1: sload_2; + sconst_1; + if_scmpne L3; + L2: aload_0; + areturn; + L3: aconst_null; + areturn; + } + + .method protected reportTestOutcome(BZ)V 9 { + .stack 3; + .locals 0; + + L0: getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sconst_0; + sload_1; + bastore; + sload_2; + ifeq L2; + L1: getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sload_1; + bspush -52; + bastore; + goto L3; + L2: getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sload_1; + sconst_0; + bastore; + L3: return; + } + + .method public process(Ljavacard/framework/APDU;)V 7 { + .stack 5; + .locals 0; + + .descriptor Ljavacard/framework/APDU; 0.10; + + L0: aload_0; + invokevirtual 10; // javacard/framework/Applet.selectingApplet()Z + ifeq L2; + L1: aload_1; + invokevirtual 11; // javacard/framework/APDU.setOutgoing()S + pop; + aload_1; + getfield_a_this 0; // reference uicc/test/util/TestToolkitApplet.baTestAppletId + sconst_0; + baload; + getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sconst_0; + baload; + sadd; + sconst_2; + sadd; + invokevirtual 12; // javacard/framework/APDU.setOutgoingLength(S)V + aload_1; + getfield_a_this 0; // reference uicc/test/util/TestToolkitApplet.baTestAppletId + sconst_0; + getfield_a_this 0; // reference uicc/test/util/TestToolkitApplet.baTestAppletId + sconst_0; + baload; + sconst_1; + sadd; + invokevirtual 13; // javacard/framework/APDU.sendBytesLong([BSS)V + aload_1; + getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sconst_0; + getfield_a_this 1; // reference uicc/test/util/TestToolkitApplet.baTestsResults + sconst_0; + baload; + sconst_1; + sadd; + invokevirtual 13; // javacard/framework/APDU.sendBytesLong([BSS)V + goto L3; + L2: sspush 27904; + invokestatic 14; // javacard/framework/ISOException.throwIt(S)V + L3: return; + } + + .method public abstract processToolkit(S)V 10 { + } + + } + + .class public UICCTestConstants 1 extends 2.0 { // extends java/lang/Object + + .fields { + public final byte[] AID_ADF1 0; // [B + public final byte[] AID_ADF2 1; // [B + public static final short FID_MF = 16128; // S + public static final short FID_EF_RFU0 = 28457; // S + public static final short FID_EF_RFU1 = 28458; // S + public static final short FID_EF_RFU2 = 28459; // S + public static final short FID_DF_RFU1 = 24321; // S + public static final short FID_DF_RFU2 = 24322; // S + public static final short FID_DF_RFU3 = 24323; // S + public static final short FID_DF_TEST = 32586; // S + public static final short FID_DF_SUB_TEST = 24336; // S + public static final short FID_DF_ADF2 = 32587; // S + public static final short FID_EF_TNR = 28417; // S + public static final short FID_EF_TNU = 28418; // S + public static final short FID_EF_TARU = 28419; // S + public static final short FID_EF_CNR = 28420; // S + public static final short FID_EF_CNU = 28421; // S + public static final short FID_EF_CNIC = 28444; // S + public static final short FID_EF_CNDE = 28423; // S + public static final short FID_EF_CNAC = 28424; // S + public static final short FID_EF_CARU = 28425; // S + public static final short FID_EF_LNR = 28426; // S + public static final short FID_EF_LNU = 28427; // S + public static final short FID_EF_LARU = 28428; // S + public static final short FID_EF_CINA = 28429; // S + public static final short FID_EF_TRAC = 28430; // S + public static final short FID_EF_TDAC = 28431; // S + public static final short FID_EF_CIAC = 28432; // S + public static final short FID_EF_CIAA = 28433; // S + public static final short FID_EF_CNRA = 28434; // S + public static final short FID_EF_CUAC = 28435; // S + public static final short FID_EF_TAAC = 28436; // S + public static final short FID_EF_LADA = 28437; // S + public static final short FID_EF_TAAA = 28438; // S + public static final short FID_EF_LRUA = 28439; // S + public static final short FID_EF_LUPC = 28440; // S + public static final short FID_EF_NOSH = 28441; // S + public static final short FID_EF_LSEA = 28442; // S + public static final short FID_EF_CSEA = 28443; // S + public static final short FID_EF_TERM = 28464; // S + public static final short FID_DF_TERM = 24368; // S + public static final short FID_EF_TAA = 20240; // S + public static final short FID_EF_LARR1 = 28577; // S + public static final short FID_EF_LARR2 = 28578; // S + public static final short FID_EF_LARR3 = 28579; // S + public static final short FID_EF_LARR4 = 28580; // S + public static final short FID_EF_LARR5 = 28581; // S + public static final short FID_EF_TARR1 = 28593; // S + public static final short FID_EF_TARR2 = 28594; // S + public static final short FID_EF_TARR3 = 28595; // S + public static final short FID_EF_TARR4 = 28596; // S + public static final short FID_EF_TARR5 = 28597; // S + public static final short FID_EF_CARR1 = 28609; // S + public static final short FID_EF_CARR2 = 28610; // S + public static final short FID_EF_CARR3 = 28611; // S + public static final short FID_EF_CARR4 = 28612; // S + public static final short FID_EF_CARR5 = 28613; // S + public static final short FID_DF_ARR1 = 24337; // S + public static final short FID_EF_TAR1T = 20241; // S + public static final short FID_DF_ARR2 = 24338; // S + public static final short FID_EF_TAR2T = 20242; // S + public static final short FID_DF_ARR3 = 24339; // S + public static final short FID_EF_TAR3T = 20243; // S + public static final short FID_DF_ARR4 = 24340; // S + public static final short FID_EF_TAR4T = 20244; // S + public static final short FID_DF_ARR5 = 24341; // S + public static final short FID_EF_TAR5T = 20245; // S + public static final short FID_EF_ARR_MF = 12038; // S + public static final short FID_EF_ARR_ADF = 28422; // S + public static final short FID_EF_UICC = 12260; // S + public static final short FID_ADF = 32767; // S + } + + .publicMethodTable 1 { + equals(Ljava/lang/Object;)Z; + } + + .packageMethodTable 0 { + } + + .method public ()V 0 { + .stack 5; + .locals 0; + + L0: aload_0; + invokespecial 15; // java/lang/Object.()V + aload_0; + bspush 16; + newarray 11; + dup; + sconst_0; + bspush -96; + bastore; + dup; + sconst_1; + sconst_0; + bastore; + dup; + sconst_2; + sconst_0; + bastore; + dup; + sconst_3; + sconst_0; + bastore; + dup; + sconst_4; + bspush 9; + bastore; + dup; + sconst_5; + sconst_0; + bastore; + dup; + bspush 6; + sconst_5; + bastore; + dup; + bspush 7; + sconst_m1; + bastore; + dup; + bspush 8; + sconst_m1; + bastore; + dup; + bspush 9; + sconst_m1; + bastore; + dup; + bspush 10; + sconst_m1; + bastore; + dup; + bspush 11; + bspush -119; + bastore; + dup; + bspush 12; + bspush -32; + bastore; + dup; + bspush 13; + sconst_0; + bastore; + dup; + bspush 14; + sconst_0; + bastore; + dup; + bspush 15; + sconst_2; + bastore; + putfield_a 3; // reference uicc/test/util/UICCTestConstants.AID_ADF1 + aload_0; + bspush 16; + newarray 11; + dup; + sconst_0; + bspush -96; + bastore; + dup; + sconst_1; + sconst_0; + bastore; + dup; + sconst_2; + sconst_0; + bastore; + dup; + sconst_3; + sconst_0; + bastore; + dup; + sconst_4; + bspush 9; + bastore; + dup; + sconst_5; + sconst_0; + bastore; + dup; + bspush 6; + sconst_5; + bastore; + dup; + bspush 7; + sconst_m1; + bastore; + dup; + bspush 8; + sconst_m1; + bastore; + dup; + bspush 9; + sconst_m1; + bastore; + dup; + bspush 10; + sconst_m1; + bastore; + dup; + bspush 11; + bspush -119; + bastore; + dup; + bspush 12; + bspush -48; + bastore; + dup; + bspush 13; + sconst_0; + bastore; + dup; + bspush 14; + sconst_0; + bastore; + dup; + bspush 15; + sconst_2; + bastore; + putfield_a 4; // reference uicc/test/util/UICCTestConstants.AID_ADF2 + return; + } + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/Api_1_Cont_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/Api_1_Cont_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a9b467da857601e60b63e4532255b98a5f3f33ff --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/Api_1_Cont_1.java @@ -0,0 +1,1662 @@ +/** + * uicc.access package, context tests + * applet 1 + */ + +package uicc.test.access.api_1_cont; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_1_Cont_1 extends TestToolkitApplet implements UICCConstants { + private boolean bRes; + private byte testCaseNb = 0; + private short i; + + private final byte SFI_EF_TNR = 0x01; + private final byte SFI_EF_TARU = 0x03; + private final byte SFI_EF_CNR = 0x04; + private final byte SFI_NA1 = 0x06; + private final byte SFI_NA2 = 0x08; + + private FileView uiccFileView1 = null; + private FileView uiccFileView2 = null; + private FileView adf1FileView1 = null; + private FileView adf1FileView2 = null; + private AdminFileView uiccAdminFileView1 = null; + private AdminFileView uiccAdminFileView2 = null; + private AdminFileView adf1AdminFileView1 = null; + private AdminFileView adf1AdminFileView2 = null; + + private static final short TLVHANDLER_MAX_SIZE = 50; + private EditHandler editHandler; + private byte[] data = null; + private byte[] resp = null; + private byte[] abExpected = null; + private byte[] abPatt = null; + private short[] asResp = null; + private byte[] checkFCP = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] adf1Aid = new byte[16]; + private UICCTestConstants uiccTestConstants; + + + private byte[] createFileEFBuffer = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x20, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFileEFBuffer_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x20, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private final short EF_FID_OFFSET = 6; + + private byte[] createFileDFBuffer = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x30, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01, (byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFileDFBuffer_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x30, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01, (byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFileDFBuffer2 = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x01, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01, (byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFileDFBuffer2_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x01, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01, (byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + + private final short DF_FID_OFFSET = 6; + + private byte[] resizeFileBuffer = new byte[] { + (byte) 0x83, (byte) 0x02, (byte) 0x00, (byte) 0x00, + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x00 + }; + + private final short RESIZE_FID_OFFSET = 2; + private final short RESIZE_SIZE_OFFSET = 7; + + private final byte[] TEXT = new byte[] { + (byte) 'C', (byte) 'o', (byte) 'n', (byte) 't', (byte) '1' + }; + + + + /** + * Constructor of the applet + */ + public Api_1_Cont_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + + data = new byte[10]; + resp = new byte[10]; + abExpected = new byte[10]; + + abPatt = new byte[10]; + asResp = new short[10]; + + checkFCP = new byte[2]; + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_1_Cont_1 thisApplet = new Api_1_Cont_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + + + private void prepareHandler(EditHandler handler, byte[] array, short offset, short fid) { + array[offset] = (byte) ((fid >> 8) & 0x00FF); + array[(short)(offset+1)] = (byte) ((fid) & 0x00FF); + handler.clear(); + handler.appendArray(array, (short) 0,(short) array.length); + } + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (testCaseNb) { + /** Testcase 0 + * + */ + case 0: + uiccFileView1 = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + uiccFileView2 = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + adf1FileView1 = UICCSystem.getTheFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + adf1FileView2 = UICCSystem.getTheFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + + uiccAdminFileView1 = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + uiccAdminFileView2 = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + adf1AdminFileView1 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + adf1AdminFileView2 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + testCaseNb++; + break; + + /** Testcase 1 + * Select and status + */ + case 1: + bRes = true; + + //1 + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_TARU); + + //2 + try { + uiccFileView1.select(UICCTestConstants.FID_ADF); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //3 + uiccFileView2.select(UICCTestConstants.FID_EF_UICC); + + //4 + try { + uiccFileView2.select(UICCTestConstants.FID_ADF); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //5 + adf1FileView1.select(UICCConstants.FID_DF_TELECOM); + + //6 + try { + adf1FileView1.select(UICCTestConstants.FID_MF); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //7 + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_DF_SUB_TEST); + + //8 + try { + adf1FileView2.select(UICCTestConstants.FID_MF); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //9,10,11,12 + try { + fcpLen = uiccFileView1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + fcpLen = uiccFileView2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + fcpLen = adf1FileView1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCConstants.FID_DF_TELECOM); + fcpLen = adf1FileView2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_SUB_TEST); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 2 + * Select SFI + */ + case 2: + bRes = true; + + //1 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(SFI_EF_TNR); + uiccFileView1.deactivateFile(); + } catch (Exception e) { + bRes = false; + } + + //2 + try { + uiccFileView1.select(SFI_NA1); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //3 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(SFI_EF_TARU); + + // update EF TARU with 01 01 + data[0] = (byte) 0x01; + data[1] = (byte) 0x01; + uiccFileView2.updateBinary((short) 0, data, (short) 0, (short) 2); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + uiccFileView2.select(SFI_NA2); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(SFI_EF_CNR); + adf1FileView1.deactivateFile(); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + adf1FileView1.select(SFI_NA1); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(SFI_EF_TARU); + + // update EF TARU with 02 02 + data[0] = (byte) 0x02; + data[1] = (byte) 0x02; + adf1FileView2.updateBinary((short) 0, data, (short) 0, (short) 2); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + adf1FileView2.select(SFI_NA2); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 3 + * ReadBinary and updateBinary + */ + case 3: + bRes = true; + + //3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_TARU); + + // update EF TARU with 01 01 01 01 + data[0] = (byte) 0x01; + data[1] = (byte) 0x01; + data[2] = (byte) 0x01; + data[3] = (byte) 0x01; + uiccFileView1.updateBinary((short) 0, data, (short) 0, (short) 4); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + uiccFileView1.readBinary((short) 0, resp, (short) 0, (short) 4); + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_TARU); + + // update EF TARU with 02 02 at offset 2 + data[2] = (byte) 0x02; + data[3] = (byte) 0x02; + uiccFileView2.updateBinary((short) 2, data, (short) 2, (short) 2); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + uiccFileView2.readBinary((short) 0, resp, (short) 0, (short) 4); + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_TARU); + + // update EF TARU with 03 03 03 03 + data[0] = (byte) 0x03; + data[1] = (byte) 0x03; + data[2] = (byte) 0x03; + data[3] = (byte) 0x03; + adf1FileView1.updateBinary((short) 0, data, (short) 0, (short) 4); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + adf1FileView1.readBinary((short) 0, resp, (short) 0, (short) 4); + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //9 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_TARU); + + // update EF TARU with 04 04 at offset 2 + data[2] = (byte) 0x04; + data[3] = (byte) 0x04; + adf1FileView2.updateBinary((short) 2, data, (short) 2, (short) 2); + } catch (Exception e) { + bRes = false; + } + + //10 + try { + adf1FileView2.readBinary((short) 0, resp, (short) 0, (short) 4); + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 4 + * SearchRecord + */ + case 4: + bRes = true; + + //3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_LUPC); + + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x22; + + uiccFileView1.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length); + bRes &= (asResp[0] == 2); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x33; + + uiccFileView1.updateRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, abPatt, + (short) 0, (short) abPatt.length); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_LUPC); + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, abPatt, + (short) 0, (short) abPatt.length); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x22; + + bRes &= (uiccFileView2.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length) == 0); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x33; + + uiccFileView2.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length); + bRes &= (asResp[0] == 2); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_LUPC); + + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x33; + + bRes &= (adf1FileView1.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length)== 0); + } catch (Exception e) { + bRes = false; + } + + //9 + try { + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x22; + + adf1FileView1.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length); + bRes &= (asResp[0] == 2); + } catch (Exception e) { + bRes = false; + } + + //10 + try { + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x11; + + adf1FileView1.updateRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, abPatt, + (short) 0, (short) abPatt.length); + } catch (Exception e) { + bRes = false; + } + + //11 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_LUPC); + + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x22; + + bRes &= (adf1FileView2.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length) == 0); + } catch (Exception e) { + bRes = false; + } + + //12 + try { + for (i = 0; i < 10; i++) + abPatt[i] = (byte) 0x11; + + adf1FileView2.searchRecord(SIMPLE_SEARCH_START_FORWARD, (short) 1, (short) 0, + abPatt, (short) 0, (short) abPatt.length, asResp, (short) 0, + (short) asResp.length); + bRes &= (asResp[0] == 1); + bRes &= (asResp[1] == 2); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 5 + * readRecord and updateRecord + */ + case 5: + bRes = true; + + //3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_LARU); + + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0x66; + + uiccFileView1.updateRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, abPatt, + (short) 0, (short) 4); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + uiccFileView1.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0xAA; + + uiccFileView1.readRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, resp, (short) 0, + (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_LARU); + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 4); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0xBB; + + uiccFileView2.updateRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short) 0, abPatt, + (short) 0, (short) 4); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0x66; + + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, resp, (short) 0, + (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //9 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0xBB; + + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, resp, (short) 0, + (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //10 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_LARU); + + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0x44; + + adf1FileView1.updateRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, abPatt, + (short) 0, (short) 4); + } catch (Exception e) { + bRes = false; + } + + //11 + try { + adf1FileView1.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //12 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0xAA; + + adf1FileView1.readRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, resp, (short) 0, + (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //13 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_LARU); + adf1FileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 4); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //14 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0x99; + + adf1FileView1.updateRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short) 0, abPatt, + (short) 0, (short) 4); + } catch (Exception e) { + bRes = false; + } + + //15 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0x44; + + adf1FileView2.readRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, resp, (short) 0, + (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //16 + try { + for (i = 0; i < 4; i++) + abPatt[i] = (byte) 0x99; + + adf1FileView2.readRecord((short) 0, REC_ACC_MODE_NEXT, (short) 0, resp, (short) 0, + (short) 4); + bRes &= (Util.arrayCompare(abPatt, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + + break; + + /** test case 6 + * ActivateFile and deactivateFile + */ + case 6: + bRes = true; + + //3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_TNU); + uiccFileView1.deactivateFile(); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_TNU); + uiccFileView2.readBinary((short) 0, resp, (short) 0, (short) 3); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + uiccFileView2.activateFile(); + uiccFileView2.readBinary((short) 0, resp, (short) 0, (short) 3); + + for (i = 0; i < 3; i++) + data[i] = (byte) 0x55; + + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + uiccFileView2.deactivateFile(); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_TNU); + adf1FileView1.readBinary((short) 0, resp, (short) 0, (short) 3); + + for (i = 0; i < 3; i++) + data[i] = (byte) 0x55; + + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + adf1FileView1.deactivateFile(); + } catch (Exception e) { + bRes = false; + } + + //9 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_TNU); + adf1FileView2.readBinary((short) 0, resp, (short) 0, (short) 3); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } catch (Exception e) { + bRes = false; + } + + //10 + try { + adf1FileView2.activateFile(); + adf1FileView2.readBinary((short) 0, resp, (short) 0, (short) 3); + + for (i = 0; i < 3; i++) + data[i] = (byte) 0x55; + + bRes &= (Util.arrayCompare(data, (short) 0, resp, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 7 + * Increase + */ + case 7: + bRes = true; + data[0] = (byte) 0; + data[1] = (byte) 0; + data[2] = (byte) 1; + + //3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_CARU); + + for (i = 0; i < 3; i++) + abPatt[i] = (byte) 0x00; + + uiccFileView1.updateRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, abPatt, + (short) 0, (short) 3); + uiccFileView1.updateRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, abPatt, + (short) 0, (short) 3); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + uiccFileView1.increase(data, (short) 0, (short) 3, resp, (short) 0); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 1; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + uiccFileView1.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 1; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + uiccFileView1.readRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 0; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_CARU); + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + uiccFileView2.increase(data, (short) 0, (short) 3, resp, (short) 0); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 2; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //9 + try { + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 2; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //10 + try { + uiccFileView2.readRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 1; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //11 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_CARU); + adf1FileView1.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //12 + try { + adf1FileView1.updateRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, abPatt, + (short) 0, (short) 3); + adf1FileView1.updateRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, abPatt, + (short) 0, (short) 3); + } catch (Exception e) { + bRes = false; + } + + //13 + try { + data[0] = (byte) 0; + data[1] = (byte) 0; + data[2] = (byte) 2; + adf1FileView1.increase(data, (short) 0, (short) 3, resp, (short) 0); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 2; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //14 + try { + adf1FileView1.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 2; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //15 + try { + adf1FileView1.readRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 0; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //16 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_CARU); + adf1FileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //17 + try { + data[0] = (byte) 0; + data[1] = (byte) 0; + data[2] = (byte) 2; + adf1FileView2.increase(data, (short) 0, (short) 3, resp, (short) 0); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 4; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //18 + try { + adf1FileView2.readRecord((short) 0, REC_ACC_MODE_CURRENT, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 4; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + + //19 + try { + adf1FileView2.readRecord((short) 0, REC_ACC_MODE_PREVIOUS, (short) 0, resp, + (short) 0, (short) 3); + abExpected[0] = (byte) 0; + abExpected[1] = (byte) 0; + abExpected[2] = (byte) 2; + bRes &= (Util.arrayCompare(resp, (short) 0, abExpected, (short) 0, (short) 3) == 0); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 8 + * CreateFile EF + */ + case 8: + bRes = true; + + + //3 + try { + uiccAdminFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView1.select(UICCTestConstants.FID_EF_RFU0); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //4 & 5 + try { + prepareHandler(editHandler, createFileEFBuffer, EF_FID_OFFSET, UICCTestConstants.FID_EF_RFU0); + uiccAdminFileView1.createFile(editHandler); + uiccAdminFileView1.select(UICCTestConstants.FID_EF_RFU0); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + uiccAdminFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView2.select(UICCTestConstants.FID_EF_RFU0); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + uiccAdminFileView2.select(UICCTestConstants.FID_EF_RFU1); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + prepareHandler(editHandler, createFileEFBuffer, EF_FID_OFFSET, UICCTestConstants.FID_EF_RFU1); + uiccAdminFileView1.createFile(editHandler); + uiccAdminFileView1.select(UICCTestConstants.FID_EF_RFU1); + } catch (Exception e) { + bRes = false; + } + + //9 & 10 + try { + uiccAdminFileView1.select(UICCTestConstants.FID_EF_RFU1); + uiccAdminFileView1.select(UICCTestConstants.FID_EF_RFU0); + } catch (Exception e) { + bRes = false; + } + + //11 + try { + adf1AdminFileView1.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView1.select(UICCTestConstants.FID_EF_RFU0); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //12 & 13 + try { + prepareHandler(editHandler, createFileEFBuffer_inADF, EF_FID_OFFSET, UICCTestConstants.FID_EF_RFU0); + adf1AdminFileView1.createFile(editHandler); + adf1AdminFileView1.select(UICCTestConstants.FID_EF_RFU0); + } catch (Exception e) { + bRes = false; + } + + //14 + try { + adf1AdminFileView2.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView2.select(UICCTestConstants.FID_EF_RFU0); + } catch (Exception e) { + bRes = false; + } + + //15 + try { + adf1AdminFileView2.select(UICCTestConstants.FID_EF_RFU1); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //16 & 17 & 18 + try { + prepareHandler(editHandler, createFileEFBuffer_inADF, EF_FID_OFFSET, UICCTestConstants.FID_EF_RFU1); + adf1AdminFileView2.createFile(editHandler); + adf1AdminFileView2.select(UICCTestConstants.FID_EF_RFU1); + adf1AdminFileView2.select(UICCTestConstants.FID_EF_RFU0); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 9 + * CreateFile DF + */ + case 9: + bRes = true; + + //3 + try { + uiccAdminFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView1.select(UICCTestConstants.FID_DF_RFU1); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //4 & 5 + try { + prepareHandler(editHandler, createFileDFBuffer, DF_FID_OFFSET, UICCTestConstants.FID_DF_RFU1); + uiccAdminFileView1.createFile(editHandler); + uiccAdminFileView1.select(UICCTestConstants.FID_DF_RFU1); + } catch (Exception e) { + bRes = false; + } + + + //6 + try { + uiccAdminFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView2.select(UICCTestConstants.FID_DF_RFU1); + } catch (Exception e) { + bRes = false; + } + + + //7 + try { + uiccAdminFileView2.select(UICCTestConstants.FID_DF_RFU2); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + prepareHandler(editHandler, createFileDFBuffer2, DF_FID_OFFSET, UICCTestConstants.FID_DF_RFU2); + uiccAdminFileView2.createFile(editHandler); + uiccAdminFileView2.select(UICCTestConstants.FID_DF_RFU2); + } catch (Exception e) { + bRes = false; + } + + + //9 & 10 + try { + uiccAdminFileView1.select(UICCTestConstants.FID_DF_RFU2); + uiccAdminFileView1.select(UICCTestConstants.FID_DF_RFU1); + } catch (Exception e) { + bRes = false; + } + + //11 + try { + adf1AdminFileView1.select(UICCTestConstants.FID_DF_RFU1); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //12 & 13 + try { + prepareHandler(editHandler, createFileDFBuffer_inADF, DF_FID_OFFSET, UICCTestConstants.FID_DF_RFU1); + adf1AdminFileView1.createFile(editHandler); + adf1AdminFileView1.select(UICCTestConstants.FID_DF_RFU1); + } catch (Exception e) { + bRes = false; + } + + //14 + try { + adf1AdminFileView2.select(UICCTestConstants.FID_DF_RFU1); + } catch (Exception e) { + bRes = false; + } + + //15 + try { + adf1AdminFileView2.select(UICCTestConstants.FID_DF_RFU2); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //16 & 17 & 18 + try { + prepareHandler(editHandler, createFileDFBuffer2_inADF, DF_FID_OFFSET, UICCTestConstants.FID_DF_RFU2); + adf1AdminFileView2.createFile(editHandler); + adf1AdminFileView2.select(UICCTestConstants.FID_DF_RFU2); + adf1AdminFileView2.select(UICCTestConstants.FID_DF_RFU1); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 10 + * ResizeFile + */ + case 10: + bRes = true; + abExpected[0] = (byte) 0x00; + abExpected[1] = (byte) 0x00; + abExpected[2] = (byte) 0x00; + abExpected[3] = (byte) 0xFF; + abExpected[4] = (byte) 0xFF; + abExpected[5] = (byte) 0xFF; + + //3 + try { + uiccAdminFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView1.select(UICCTestConstants.FID_EF_TDAC); + uiccAdminFileView1.readBinary((short) 0, resp, (short) 0, (short) 6); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + resizeFileBuffer[RESIZE_FID_OFFSET] = (byte) ((UICCTestConstants.FID_EF_TDAC >> 8) & 0x00FF); + resizeFileBuffer[RESIZE_FID_OFFSET+1] = (byte) (UICCTestConstants.FID_EF_TDAC & 0x00FF); + resizeFileBuffer[RESIZE_SIZE_OFFSET]= (byte) 0x06; // new size: add 3 + prepareHandler(editHandler, resizeFileBuffer, RESIZE_FID_OFFSET, UICCTestConstants.FID_EF_TDAC); + uiccAdminFileView1.resizeFile(editHandler); + uiccAdminFileView1.readBinary((short) 0, resp, (short) 0, (short) 6); + bRes &= (Util.arrayCompare(abExpected, (short) 0, resp, (short) 0, (short) 6) == 0); + } catch (Exception e) { + bRes = false; + } + + //5 + try { + uiccAdminFileView2.select(UICCTestConstants.FID_MF); + uiccAdminFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView2.select(UICCTestConstants.FID_EF_TDAC); + uiccAdminFileView2.readBinary((short) 0, resp, (short) 0, (short) 6); + bRes &= (Util.arrayCompare(abExpected, (short) 0, resp, (short) 0, (short) 6) == 0); + } catch (Exception e) { + bRes = false; + } + + //6 + try { + resizeFileBuffer[RESIZE_SIZE_OFFSET] = (byte) 0x04; // new size: remove 2 + prepareHandler(editHandler, resizeFileBuffer, RESIZE_FID_OFFSET, UICCTestConstants.FID_EF_TDAC); + uiccAdminFileView1.resizeFile(editHandler); + } catch (Exception e) { + bRes = false; + } + + //7 + try { + adf1AdminFileView1.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView1.select(UICCTestConstants.FID_EF_LNU); + adf1AdminFileView1.readRecord((short) 4, REC_ACC_MODE_ABSOLUTE, (short) 0, abPatt, + (short) 0, (short) 4); + bRes = false; + } catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + //8 + try { + resizeFileBuffer[RESIZE_FID_OFFSET] = (byte) ((UICCTestConstants.FID_EF_LNU >> 8) & 0x00FF); + resizeFileBuffer[RESIZE_FID_OFFSET+1] = (byte) (UICCTestConstants.FID_EF_LNU & 0x00FF); + resizeFileBuffer[RESIZE_SIZE_OFFSET] = (byte) 0x10; // new size: add 2 records + prepareHandler(editHandler, resizeFileBuffer, RESIZE_FID_OFFSET, UICCTestConstants.FID_EF_LNU); + adf1AdminFileView1.resizeFile(editHandler); + adf1AdminFileView1.readRecord((short) 4, REC_ACC_MODE_ABSOLUTE, (short) 0, resp, + (short) 0, (short) 4); + abExpected[0] = (byte) 0xFF; + abExpected[1] = (byte) 0xFF; + abExpected[2] = (byte) 0xFF; + abExpected[3] = (byte) 0xFF; + bRes &= (Util.arrayCompare(abExpected, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //9 + try { + adf1AdminFileView2.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView2.select(UICCTestConstants.FID_EF_LNU); + adf1AdminFileView2.readRecord((short) 4, REC_ACC_MODE_ABSOLUTE, (short) 0, resp, + (short) 0, (short) 4); + bRes &= (Util.arrayCompare(abExpected, (short) 0, resp, (short) 0, (short) 4) == 0); + } catch (Exception e) { + bRes = false; + } + + //10 + try { + resizeFileBuffer[RESIZE_SIZE_OFFSET] = (byte) 0x0C; // new size: remove 1 record + prepareHandler(editHandler, resizeFileBuffer, RESIZE_FID_OFFSET, UICCTestConstants.FID_EF_LNU); + adf1AdminFileView2.resizeFile(editHandler); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + + /** test case 11 + * Non-shareable files (UICCFileView - UICCFileView) + */ + case 11: + bRes = true; + + //3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_NOSH); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_NOSH); + bRes = false; + } catch (UICCException e) { + bRes =true;//&= ((e.getReason() == UICCException.FILE_NOT_FOUND)||(e.getReason() == UICCException.INTERNAL_ERROR)); // TODO: clarification Cf AP22 -> NOT_FOUND OR INTERNAL_ERROR + } catch (Exception e) { + bRes = false; + } + + //5 & 6 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_NOSH); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 12 + * Non-shareable files (FileView - FileView) + */ + case 12: + bRes = true; + + //3 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_NOSH); + } catch (Exception e) { + bRes = false; + } + + //4 + try { + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_NOSH); + bRes = false; + } catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.FILE_NOT_FOUND)||(e.getReason() == UICCException.INTERNAL_ERROR)); // TODO: clarification Cf AP22 -> NOT_FOUND OR INTERNAL_ERROR + } catch (Exception e) { + bRes = false; + } + + //5 & 6 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_NOSH); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 13 + * Non-shareable files (UICCFileView - MF) + */ + case 13: + bRes = true; + + //2 & 3 + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_NOSH); + + ProactiveHandler proactiveHandler = ProactiveHandlerSystem.getTheHandler(); + proactiveHandler.initDisplayText((byte) 0x80, (byte) 0x04, TEXT, (short) 0x00, + (short) TEXT.length); + proactiveHandler.send(); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 14 + * Non-shareable files (FileView - ADF) + */ + case 14: + bRes = true; + + //2 & 3 + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_NOSH); + + ProactiveHandler proactiveHandler = ProactiveHandlerSystem.getTheHandler(); + proactiveHandler.initDisplayText((byte) 0x80, (byte) 0x04, TEXT, (short) 0x00, + (short) TEXT.length); + proactiveHandler.send(); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 15 + * Non-shareable files (MF - UICCFileView) + */ + case 15: + bRes = true; + + try { + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_NOSH); + bRes = false; + } catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.FILE_NOT_FOUND)||(e.getReason() == UICCException.INTERNAL_ERROR)); // TODO: clarification Cf AP22 -> NOT_FOUND OR INTERNAL_ERROR + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + /** test case 16 + * Non-shareable files (ADF - FileView) + */ + case 16: + bRes = true; + + try { + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_NOSH); + bRes = false; + } catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.FILE_NOT_FOUND)||(e.getReason() == UICCException.INTERNAL_ERROR)); // TODO: clarification Cf AP22 -> NOT_FOUND OR INTERNAL_ERROR + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + break; + + + /** test case 17 + * Terminated EF/DF + */ + case 17: + bRes = true; + + try { + uiccAdminFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView1.select(UICCTestConstants.FID_EF_TERM); + } catch (Exception e) { + bRes = false; + } + + try { + uiccAdminFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView1.select(UICCTestConstants.FID_DF_TERM); + } catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + break; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/Test_Api_1_Cont.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/Test_Api_1_Cont.java new file mode 100644 index 0000000000000000000000000000000000000000..46afa88e91349ea3c99c803057d0532fb283784e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/Test_Api_1_Cont.java @@ -0,0 +1,560 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access package part 1 + * Test source for context tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_cont; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_1_Cont extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/api_1_cont"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + static final String DF_TELECOM = "7F10"; + static final String MF = "3F00"; + static final String DF_TEST = "7F4A"; + static final String EF_TNR = "6F01"; + static final String EF_TNU = "6F02"; + static final String EF_TARU = "6F03"; + static final String EF_CNR = "6F04"; + static final String EF_CARU = "6F09"; + static final String EF_LNU = "6F0B"; + static final String EF_LARU = "6F0C"; + static final String EF_TDAC = "6F0F"; + static final String EF_LUPC = "6F18"; + static final String EF_NOSH = "6F19"; + static final String EF_RFU0 = "6F29"; + static final String EF_RFU1 = "6F2A"; + static final String DF_RFU1 = "5F01"; + static final String DF_RFU2 = "5F02"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_1_Cont() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + /** test case 0 + * Init + */ + // select DF_TELECOM + test.selectFile(MF); + test.selectFile(DF_TELECOM); + test.unrecognizedEnvelope(); + + /** test case 1 + * Select and status + */ + test.unrecognizedEnvelope(); + + + /** test case 2 + * Select SFI + */ + test.unrecognizedEnvelope(); + + //9 + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_TNR); + + //10 + response = test.activate(EF_TNR); + result &= response.checkSw("9000"); + + //11 + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_TARU); + + //12 + response = test.readBinary("0000", "02"); + result &= response.checkData("0101"); + + //13 + test.updateBinary("0000", "FFFFFF"); + + //14 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(EF_CNR); + + //15 + response = test.activate(EF_CNR); + result &= response.checkSw("9000"); + + //16 + test.selectFile(EF_TARU); + + //17 + response = test.readBinary("0000", "02"); + result &= response.checkData("0202"); + + //18 + test.updateBinary("0000", "FFFFFF"); + + /** test case 3 + * ReadBinary and updateBinary + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //11 + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_TARU); + response = test.readBinary("0000", "04"); + result &= response.checkData("01010202"); + + //12 + test.updateBinary("0000", "FFFFFFFF"); + + //13 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(EF_TARU); + response = test.readBinary("0000", "04"); + result &= response.checkData("03030404"); + + //14 + test.updateBinary("0000", "FFFFFFFF"); + + /** test case 4 + * SearchRecord + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + test.verifyPIN("01","31313131FFFFFFFF"); + //Verify ADM2 + test.verifyPIN("0B","3232323232323232"); + //2 + test.unrecognizedEnvelope(); + + + + //13 + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_LUPC); + response = test.readRecord("01", "04", "0A"); + result &= response.checkData("11111111 11111111 1111"); + + //14 + response = test.readRecord("02", "04", "0A"); + result &= response.checkData("33333333 33333333 3333"); + + //15 + test.updateRecord("01", "04", "11111111 11111111 1111"); + + //16 + test.updateRecord("02", "04", "22222222 22222222 2222"); + + //17 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(EF_LUPC); + response = test.readRecord("01", "04", "0A"); + result &= response.checkData("11111111 11111111 1111"); + + //18 + response = test.readRecord("02", "04", "0A"); + result &= response.checkData("11111111 11111111 1111"); + + //19 + test.updateRecord("01", "04", "11111111 11111111 1111"); + + //20 + test.updateRecord("02", "04", "22222222 22222222 2222"); + + /** test case 5 + * readRecord and updateRecord + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //17 + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_LARU); + response = test.readRecord("00", "02", "04"); + result &= response.checkData("66666666"); + + //18 + response = test.readRecord("00", "02", "04"); + result &= response.checkData("BBBBBBBB"); + + //19 + test.updateRecord("01", "04", "55555555"); + + //20 + test.updateRecord("02", "04", "AAAAAAAA"); + + //21 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(EF_LARU); + response = test.readRecord("00", "02", "04"); + result &= response.checkData("44444444"); + + //22 + response = test.readRecord("00", "02", "04"); + result &= response.checkData("99999999"); + + //23 + test.updateRecord("01", "04", "55555555"); + + //24 + test.updateRecord("02", "04", "AAAAAAAA"); + + /** test case 6 + * ActivateFile and deactivateFile + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //11 + test.selectFile(DF_TEST); + response = test.selectFile(EF_TNU); + result &= response.checkSw("6283"); + + //12 + response = test.activate(EF_TNU); + result &= response.checkSw("9000"); + + //13 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + response = test.selectFile(EF_TNU); + result &= response.checkSw("9000"); + + /** test case 7 + * Increase + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //20 + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + response = test.readRecord("00", "04", "03"); + result &= response.checkSw("6A83"); + + //21 + response = test.readRecord("00", "03", "03"); + result &= response.checkData("000001"); + + //22 + response = test.readRecord("00", "03", "03"); + result &= response.checkData("000002"); + + //23 + response = test.updateRecord("00", "03", "AAAAAA"); + result &= response.checkSw("9000"); + + //24 + response = test.updateRecord("00", "03", "555555"); + result &= response.checkSw("9000"); + + //25 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + response = test.readRecord("00", "04", "03"); + result &= response.checkSw("6A83"); + + //26 + response = test.readRecord("00", "03", "03"); + result &= response.checkData("000002"); + + //27 + response = test.readRecord("00", "03", "03"); + result &= response.checkData("000004"); + + //28 + response = test.updateRecord("00", "03", "AAAAAA"); + result &= response.checkSw("9000"); + + //29 + response = test.updateRecord("00", "03", "555555"); + result &= response.checkSw("9000"); + + + + /** test case 8 + * CreateFile EF + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //21 + test.selectFile(DF_TEST); + result &= test.selectFile(EF_RFU0).checkSw("9000"); + + //22 + result &= test.selectFile(EF_RFU1).checkSw("9000"); + + //23 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + result &= test.selectFile(EF_RFU0).checkSw("9000"); + + //24 + result &= test.selectFile(EF_RFU1).checkSw("9000"); + + /** test case 9 + * CreateFile DF + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //21 + test.selectFile(DF_TEST); + result &= test.selectFile(DF_RFU1).checkSw("9000"); + + //22 + result &= test.selectFile(DF_RFU2).checkSw("9000"); + + //23 + test.selectApplication(AID_ADF_1); + result &= test.selectFile(DF_RFU1).checkSw("9000"); + + //24 + result &= test.selectFile(DF_RFU2).checkSw("9000"); + + + /** test case 10 + * ResizeFile + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.unrecognizedEnvelope(); + + //11 + test.selectFile(DF_TEST); + test.selectFile(EF_TDAC); + response = test.readBinary("0000", "06"); + result &=(response.checkSw("9000")||response.checkSw("6282")||response.checkSw("6700")); + if (response.checkSw("9000")) + { + result &= response.checkData("000000FF"); + } + + //12 + result &= test.readBinary("0000", "04").checkData("000000FF"); + + //13 + result &= test.resizeFile(EF_TDAC, "03").checkSw("9000"); + + //14 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(EF_LNU); + response = test.readRecord("00", "04", "04"); + result &= response.checkSw("6A83"); + + //15 + response = test.readRecord("00", "03", "04"); + result &= response.checkData("FFFFFFFF"); + + //16 + result &= test.resizeFile(EF_LNU, "08").checkSw("9000"); + + + + /** test cases 11 & 12 + * Non-shareable files (UICCFileView - UICCFileView) + * Non-shareable files (FileView - FileView) + */ + test.reset(); + test.terminalProfileSession("0101"); + test.unrecognizedEnvelope(); + test.reset(); + test.terminalProfileSession("010101"); + test.unrecognizedEnvelope(); + + /** test case 13 + * Non-shareable files (UICCFileView - MF) + */ + //1 + test.unrecognizedEnvelope(); + + //4 + test.selectFile(DF_TEST); + result &= test.selectFile(EF_NOSH).checkSw("6985"); + + //5 + test.fetch("13"); + response = test.terminalResponse("81030121 80820282 81830100"); + + /** test case 14 + * Non-shareable files (FileView - ADF) + */ + //1 + test.unrecognizedEnvelope(); + + //4 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + result &= test.selectFile(EF_NOSH).checkSw("6985"); + + //5 + test.fetch("13"); + response = test.terminalResponse("81030121 80820282 81830100"); + + /** test case 15 + * Non-shareable files (MF - UICCFileView) + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.selectFile(DF_TEST); + result &= test.selectFile(EF_NOSH).checkSw("9000"); + + //3 + test.unrecognizedEnvelope(); + + /** test case 16 + * Non-shareable files (ADF - FileView) + */ + //1 + test.reset(); + test.terminalProfileSession("0101"); + + //2 + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + result &= test.selectFile(EF_NOSH).checkSw("9000"); + + //3 + test.unrecognizedEnvelope(); + + + /** test case 17 + * Terminated EF/DF + */ + + test.reset(); + test.terminalProfileSession("0101"); + test.unrecognizedEnvelope(); + + /** Remove the created test EF + * + */ + + test.selectFile(MF); + test.selectFile(DF_TEST); + test.deleteFile(DF_RFU1); + test.deleteFile(EF_RFU0); + test.deleteFile(EF_RFU1); + + + test.selectApplication(AID_ADF_1); + test.deleteFile(DF_RFU1); + test.selectFile(DF_TEST); + test.deleteFile(EF_RFU0); + test.deleteFile(EF_RFU1); + + + + /** + * Check Results and delete packages + */ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "11CCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCC"); + + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..85eff8f7a2ccc4ebbf1da2c2ecf2da229c97856e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_cont.Api_1_Cont_1 +uicc.test.access.api_1_cont +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/javacard/api_1_cont.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/javacard/api_1_cont.cap new file mode 100644 index 0000000000000000000000000000000000000000..df2149848761b2463405f6892c61e7baf9da905b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_cont/javacard/api_1_cont.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/Api_1_Fvw_Actf_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/Api_1_Fvw_Actf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..74d16816ccafad0da238b98cadbea79d07b12b9a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/Api_1_Fvw_Actf_1.java @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Actf_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_actf; + +import uicc.test.util.* ; +import javacard.framework.*; +import uicc.access.* ; + + +public class Api_1_Fvw_Actf_1 extends TestToolkitApplet +{ + private FileView UiccFileView = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Actf_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Actf_1 thisApplet = new Api_1_Fvw_Actf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + UiccFileView.activateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : Activate a deactivated file + // ----------------------------------------------------------------- + testCaseNb = 2; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_MF); + UiccFileView.select((short)UICCTestConstants.FID_EF_UICC); + // Points 2 and 3 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + UiccFileView.deactivateFile(); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + // Point 4 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.REF_DATA_INVALIDATED) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + // Point 5 and 6 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.activateFile(); + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + bRes &= true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Activate an activated file + // ----------------------------------------------------------------- + testCaseNb = 3; + bRes = false; + try + { + UiccFileView.activateFile(); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : Access condition not fulfilled + // ----------------------------------------------------------------- + testCaseNb = 4; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + UiccFileView.select((short)UICCTestConstants.FID_EF_LADA); + try + { + UiccFileView.activateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/Test_Api_1_Fvw_Actf.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/Test_Api_1_Fvw_Actf.java new file mode 100644 index 0000000000000000000000000000000000000000..00c6eba92061487cc48bff2e7ffc4b0109972bd1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/Test_Api_1_Fvw_Actf.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_actf; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Actf extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_actf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Actf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402FFFDFF" + // LV Access Domain for UICC file system = All except ADM2 + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402FFFDFF" + // LV Access Domain for ADF1 file system = All except ADM22 + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04" + "CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..530c9a9dc8ae4ac80787092fa6e10fe11b8f7b8f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_actf.Api_1_Fvw_Actf_1 +uicc.test.access.api_1_fvw_actf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/javacard/api_1_fvw_actf.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/javacard/api_1_fvw_actf.cap new file mode 100644 index 0000000000000000000000000000000000000000..c65c6914ef45b249589c039b76a549edb3f2f26f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_actf/javacard/api_1_fvw_actf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/Api_1_Fvw_Dacf_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/Api_1_Fvw_Dacf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e7d3c2d2e7b4ded614c29d50d560dbc4d90eed28 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/Api_1_Fvw_Dacf_1.java @@ -0,0 +1,153 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Dacf_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_dacf; + +import uicc.test.util.* ; +import javacard.framework.*; +import uicc.access.* ; + + +public class Api_1_Fvw_Dacf_1 extends TestToolkitApplet +{ + private FileView UiccFileView = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Dacf_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Dacf_1 thisApplet = new Api_1_Fvw_Dacf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + UiccFileView.deactivateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : Deactivate an activated file + // ----------------------------------------------------------------- + testCaseNb = 2; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_MF); + UiccFileView.select((short)UICCTestConstants.FID_EF_UICC); + // Points 2, 3 and 4 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + UiccFileView.deactivateFile(); + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.REF_DATA_INVALIDATED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Deactivate a deactivated file + // ----------------------------------------------------------------- + testCaseNb = 3; + bRes = false; + try + { + UiccFileView.deactivateFile(); + bRes = true; + // Restore EFuicc in its initial state + UiccFileView.activateFile(); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : Access condition not fulfilled + // ----------------------------------------------------------------- + testCaseNb = 4; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + UiccFileView.select((short)UICCTestConstants.FID_EF_LADA); + try + { + UiccFileView.deactivateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/Test_Api_1_Fvw_Dacf.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/Test_Api_1_Fvw_Dacf.java new file mode 100644 index 0000000000000000000000000000000000000000..f0c9e0e8a9b8390c139954937ad072aa99884e38 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/Test_Api_1_Fvw_Dacf.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_dacf; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Dacf extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_dacf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Dacf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402FFFDFF" + // LV Access Domain for UICC file system = All except ADM2 + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402FFFDFF" + // LV Access Domain for ADF1 file system = All except ADM2 + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04" + "CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..8da98164fa8590e9d7d61db2b9dca31a9641a383 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_dacf.Api_1_Fvw_Dacf_1 +uicc.test.access.api_1_fvw_dacf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/javacard/api_1_fvw_dacf.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/javacard/api_1_fvw_dacf.cap new file mode 100644 index 0000000000000000000000000000000000000000..f3fa8750fae68e4a98ee481c127948fb49a091d4 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_dacf/javacard/api_1_fvw_dacf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/Api_1_Fvw_Incr_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/Api_1_Fvw_Incr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6bd00d91583ce0d4da9c2d0fb306a310642602a5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/Api_1_Fvw_Incr_1.java @@ -0,0 +1,574 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Incr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_incr; + +import uicc.system.HandlerBuilder; +import uicc.test.util.* ; +import uicc.toolkit.ViewHandler; +import javacard.framework.*; +import uicc.access.* ; +import uicc.access.fileadministration.*; + + +public class Api_1_Fvw_Incr_1 extends TestToolkitApplet implements UICCConstants +{ + private FileView UiccFileView = null; + private AdminFileView UiccAdminFileView = null; + private ViewHandler createEFCmd = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private byte [] abCreateEF = { + (byte)0x82,(byte)0x04, // Tag, Length - File descriptor + (byte)0x46,(byte)0x21,(byte)0x00,(byte)0x7F, // Value - File descriptor (Cyclic) and record length (0x7F) + (byte)0x83,(byte)0x02, // Tag, Length - File Id + (byte)0x2C,(byte)0x7F, // Value - File Id + (byte)0x8A,(byte)0x01,(byte)0x05, // Tag, Length, Value - LCSI (Activated) + (byte)0x8B,(byte)0x03, // Tag, Length - Security attribute + (byte)0x2F,(byte)0x06,(byte)0x01, // Value - Security attribute (EF Arr, record nb) + (byte)0x80,(byte)0x02,(byte)0x00,(byte)0x7F, // Tag, Length, value - File size (0 bytes => no record) + (byte)0x88,(byte)0x00}; // Tag, Length - SFI (no SFI) + byte testCaseNb = (byte) 0x00; + byte incr[] = null; + byte resp[] = null; + byte data[] = null; + byte comp[] = null; + short incrOffset = 0; + short respOffset = 0; + short incrLength = 0; + short respLength = 0; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Incr_1() + { + incr = new byte[4]; + resp = new byte[4]; + comp = new byte[4]; + data = new byte[3]; + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Incr_1 thisApplet = new Api_1_Fvw_Incr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + UiccAdminFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + incrLength = 2; + UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : increase , verify response + // ----------------------------------------------------------------- + testCaseNb = 2; + UiccFileView.select((short)UICCTestConstants.FID_EF_CARU); + try + { + // Set records to 00 00 00 + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incr[2] = (byte)1; + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + + // Verify result + Util.arrayFillNonAtomic(comp, (short)0, (short)comp.length, (byte)0); + comp[2] = (byte)1; + if ((respLength == (short)3) && + (Util.arrayCompare(resp, (short)0, comp, (short)0, (short)4) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : increase , verify file + // ----------------------------------------------------------------- + testCaseNb = 3; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incr[3] = (byte)2; + incrOffset = 1; + incrLength = 3; + respOffset = 1; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + + // Verify result + Util.arrayFillNonAtomic(resp, (short)0, (short)resp.length, (byte)0); + Util.arrayFillNonAtomic(comp, (short)0, (short)comp.length, (byte)0); + comp[2] = (byte)3; + UiccFileView.readRecord((short)0, REC_ACC_MODE_CURRENT, (short)0, resp, (short)0, (short)3); + if ((respLength == (short)3) && + (Util.arrayCompare(resp, (short)0, comp, (short)0, (short)4) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : incr[] is null + // ----------------------------------------------------------------- + testCaseNb = 4; + try + { + // increase + incrOffset = 0; + incrLength = 1; + respOffset = 0; + respLength = UiccFileView.increase(null, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 5 : incrLength < 0 + // ----------------------------------------------------------------- + testCaseNb = 5; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = -1; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6 : incrOffset < 0 + // ----------------------------------------------------------------- + testCaseNb = 6; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = -1; + incrLength = 1; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7 : IncrOffset + incrLength > incr.length + // ----------------------------------------------------------------- + testCaseNb = 7; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 1; + incrLength = 4; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 8 : Reach Maximum Value + // ----------------------------------------------------------------- + testCaseNb = 8; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0xFF); + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.MAX_VALUE_REACHED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + + try + { + // Set records to FF FF FF + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0xFF); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incr[2] = (byte)1; + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.MAX_VALUE_REACHED) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 9 : resp[] is null + // ----------------------------------------------------------------- + testCaseNb = 9; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0xFF); + incrOffset = 0; + incrLength = 1; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, null, respOffset); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 10 : incrLength < 0 + // ----------------------------------------------------------------- + testCaseNb = 10; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = 1; + respOffset = -1; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 11 : respOffset + recordLength > resp.length + // ----------------------------------------------------------------- + testCaseNb = 11; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = 3; + respOffset = 2; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 12 : Ef is not cyclic + // ----------------------------------------------------------------- + testCaseNb = 12; + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_TARU); + incr = new byte[3]; + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.COMMAND_INCOMPATIBLE) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_LARU); + // increase + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.COMMAND_INCOMPATIBLE) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 13 : Access condition not fulfilled + // ----------------------------------------------------------------- + testCaseNb = 13; + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_CNIC); + // increase + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 14 : EF is deactivated + // ----------------------------------------------------------------- + testCaseNb = 14; + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_CARU); + // deactivated + UiccFileView.deactivateFile(); + // increase + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.REF_DATA_INVALIDATED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + // activate + UiccFileView.activateFile(); + // Restore Ef content + // Set records to 55 55 55 + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0x55); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + // Set records to AA AA AA + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0xAA); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + bRes &= true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 15 : incrLength out of range + // ----------------------------------------------------------------- + testCaseNb = 15; + try + { + // Create EF 0x2CFD + incr = new byte[128]; + resp = new byte[0xFF]; + comp = new byte[0xFF]; + createEFCmd = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, (short)abCreateEF.length, abCreateEF, (short)0x00, (short)abCreateEF.length); + UiccAdminFileView.createFile(createEFCmd); + UiccAdminFileView.select((short)0x2C7F); + + Util.arrayFillNonAtomic(comp, (short)0, (short)127, (byte)0xFF); + comp[0] = (byte)0x00; + UiccAdminFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, comp, (short)0, (short)127); + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + Util.arrayFillNonAtomic(resp, (short)0, (short)resp.length, (byte)0); + Util.arrayFillNonAtomic(comp, (short)0, (short)resp.length, (byte)0); + incr[127] = (byte)0x01; + comp[0] = (byte)0x01; + incrOffset = 1; + incrLength = 127; + respOffset = 0; + respLength = UiccAdminFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + // Check result + if ((respLength == (short)0x7F) && + (Util.arrayCompare(resp, (short)0, comp, (short)0, respLength) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + // increase + incrOffset = 0; + incrLength = 128; + respOffset = 0; + respLength = UiccAdminFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (Exception e) + { + bRes &= true; + } + reportTestOutcome(testCaseNb, bRes); + UiccAdminFileView.deleteFile((short)0x2C7F); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/Test_Api_1_Fvw_Incr.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/Test_Api_1_Fvw_Incr.java new file mode 100644 index 0000000000000000000000000000000000000000..9290f49fa3f704b11f01f72063602a7eaa5f4655 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/Test_Api_1_Fvw_Incr.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_incr; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Incr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_incr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Incr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" + // LV Access Domain DAP field + "8218" + // TLV UICC Admin Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0F" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7c80a12498bdfc49910db1dba085851562a4abb4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_incr.Api_1_Fvw_Incr_1 +uicc.test.access.api_1_fvw_incr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/javacard/api_1_fvw_incr.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/javacard/api_1_fvw_incr.cap new file mode 100644 index 0000000000000000000000000000000000000000..059938114a750cd20092b1f6da0bf8695001c433 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_incr/javacard/api_1_fvw_incr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/Api_1_Fvw_Redb_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/Api_1_Fvw_Redb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..65aa4dea14a5b773b247b0d89fc532d70a6e7b51 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/Api_1_Fvw_Redb_1.java @@ -0,0 +1,361 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Redb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_redb; + +import javacard.framework.*; +import uicc.access.*; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_redb + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ + +public class Api_1_Fvw_Redb_1 extends TestToolkitApplet implements UICCConstants +{ + private FileView UiccFileView = null; + + final short RESP_BUFFER_LENGTH = (short)0x0104; + + byte[] resp = new byte[RESP_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[RESP_BUFFER_LENGTH]; + byte[] nullBuffer = null; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Redb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Redb_1 thisApplet = new Api_1_Fvw_Redb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short result = 0; + short respOffset = 0; + short respLength = 0; + short fileOffset = 0; + + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TEST CASE 01: Read from a transparent file at offset 0 + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + + fileOffset = 0; + respOffset = 10; + respLength = 250; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0xFF); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)10,(byte)0x55); + // Initialise resp buffer + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0x55); + + // Call the readBinary() method + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 02: Read from a transparent file at a given offset + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + try { + + fileOffset = (short)0x80; + respOffset = (short)0x80; + respLength = 5; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)respOffset,(short)respLength,(byte)0xFF); + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Errorcase, fileOffset is negative + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + fileOffset = (short)-1; + respOffset = 0; + respLength = 10; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Errorcase, fileOffset + respLength > EF length + *------------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + fileOffset = (short)259; + respOffset = 0; + respLength = 2; + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Errorcase, resp is null + *------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + fileOffset = 0; + respOffset = 0; + respLength = 10; + result = UiccFileView.readBinary(fileOffset, nullBuffer, respOffset, respLength); + bRes = false; + } + catch (NullPointerException npe) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 06: Errorcase, respOffset < 0 + *-------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + fileOffset = 0; + respOffset = (short)-1; + respLength = 10; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 07: Errorcase, respLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + fileOffset = 0; + respOffset = 0; + respLength = (short)-1; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 08: Errorcase, respOffset + respLength > resp.Length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + fileOffset = 0; + respOffset = 0xFA; + respLength = 0x0B; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 09: Errorcase, EF is not transparent + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + fileOffset = 0; + respOffset = 0; + respLength = 1; + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Errorcase, Access condition not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TNR); + + fileOffset = 0; + respOffset = 0; + respLength = 1; + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Errorcase, EF is invalidated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_TNU); + UiccFileView.deactivateFile(); + + try { + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + + reportTestOutcome(testCaseNb,bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/Test_Api_1_Fvw_Redb.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/Test_Api_1_Fvw_Redb.java new file mode 100644 index 0000000000000000000000000000000000000000..3d627a4fe1916e44730f868db9c59badbca2f6f1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/Test_Api_1_Fvw_Redb.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Tvw_Redb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_redb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_redb + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_1_Fvw_Redb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_redb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Redb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession("0101"); + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..80e1bc398da07f9b509885ea4a190e8c0bc28c31 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_redb.Api_1_Fvw_Redb_1 +uicc.test.access.api_1_fvw_redb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/javacard/api_1_fvw_redb.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/javacard/api_1_fvw_redb.cap new file mode 100644 index 0000000000000000000000000000000000000000..bb80e1c3aff135deb1a6e05a2a285b844e968fe1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redb/javacard/api_1_fvw_redb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/Api_1_Fvw_Redr_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/Api_1_Fvw_Redr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ad54ebc7d727df41e6a6971300d21d941fadca60 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/Api_1_Fvw_Redr_1.java @@ -0,0 +1,851 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Redr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_redr; + +import javacard.framework.*; +import uicc.access.*; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_redr + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_1_Fvw_Redr_1 extends TestToolkitApplet implements UICCConstants +{ + private FileView UiccFileView = null; + + final short RESP_BUFFER_LENGTH = (short)0x14; + + byte[] resp = new byte[RESP_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[RESP_BUFFER_LENGTH]; + byte[] nullBuffer = null; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Redr_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Redr_1 thisApplet = new Api_1_Fvw_Redr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short result = 0; + short respOffset = 0; + short respLength = 0; + short fileOffset = 0; + short recOffset = 0; + byte recNumber = 0; + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*----------------------------------------------------------------------------------- + * TEST CASE 01: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + recNumber = 1; + respOffset = 0; + respLength = 0x0A; + + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + /*---------------------------------------------------------------- + * TEST CASE 02: Read Absolute from a linear fixed file + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Test case 1.1: Record pointer not set + recNumber = 2; + respOffset = 0; + respLength = 0x04; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0x55); + // Initialise resp buffer + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0x00); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Test case 1.2 : read record in next mode + recNumber = 0; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0xAA); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Read current from linear fixed EF + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Read next from a linear fixed file + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Select EF LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0xAA); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Read next from linear fixed EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 06: Read previous from linear fixed EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Select EF LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Call the readRecord() method to set the record pointer to the first record + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 07: Read previous from a linear fixed file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 08: Read absolute from Cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + // Read record 2 + recNumber = 2; + respOffset = 0; + respLength = 0x03; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0x00); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + // Initialise the resp buffer + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0x00); + + // Select EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Read record 1 + recNumber = 1; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Call the readRecord() method in NEXT mode to set the record pointer + recNumber = 0; + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: Read current from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Read next from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Read Next from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Select EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Read previous from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 13: Read previous from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0D; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Select EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 14: Read absolute from linear fixed beyond record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0E; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + respLength = (short)0x04; + + try { + recNumber = (short)-1; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)3; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 15: Read current from linear fixed file with no current record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0F; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)0; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 16: Read absolute with recOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x10; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)1; + recOffset = (short)-1; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 17: Read absolute with recOffset + respLength > record length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x11; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)0x01; + recOffset = (short)0x02; + respLength = (short)0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 18: Read with invalid mode + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x12; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + recNumber = (short)0x00; + recOffset = (short)0x00; + respLength = (short)0x04; + + try { + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,(byte)1,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + try { + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,(byte)5,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 19: resp buffer is null + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x13; + bRes = false; + + try { + recNumber = 1; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,null,respOffset,respLength); + bRes = false; + } + catch(NullPointerException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 20: respOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x14; + bRes = false; + + try { + recNumber = 1; + respOffset = (short)-1; + respLength = 4; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 21: respLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x15; + bRes = false; + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)-1; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 22: respLength + respOffset > resp.length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x16; + bRes = false; + + try { + recNumber = 1; + respOffset = (short)0x11; + respLength = (short)4; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 23: EF is not a record file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x17; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)4; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 24: Access not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x18; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CNR); + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)3; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 25: EF is deactivated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x19; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CNU); + UiccFileView.deactivateFile(); + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)3; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + reportTestOutcome(testCaseNb,bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/Test_Api_1_Fvw_Redr.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/Test_Api_1_Fvw_Redr.java new file mode 100644 index 0000000000000000000000000000000000000000..97768fcf03363e57bdee493c4ba58aceb00cc720 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/Test_Api_1_Fvw_Redr.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Fvw_Redr.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_redr; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_redr + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_1_Fvw_Redr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_redr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Redr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "19CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession("0101"); + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..67f8ab18dbda685dc2f4ef8e826b084ee3f86950 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_redr.Api_1_Fvw_Redr_1 +uicc.test.access.api_1_fvw_redr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/javacard/api_1_fvw_redr.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/javacard/api_1_fvw_redr.cap new file mode 100644 index 0000000000000000000000000000000000000000..d0ba5bfd99479878a9abc09d0c8fa871c4256475 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_redr/javacard/api_1_fvw_redr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/Api_1_Fvw_Sear_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/Api_1_Fvw_Sear_1.java new file mode 100644 index 0000000000000000000000000000000000000000..9f310d0a8a95ddd0bbac428f23577a552770a77f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/Api_1_Fvw_Sear_1.java @@ -0,0 +1,1841 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Sear_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_sear; + +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.access.* ; +import uicc.test.util.* ; + + +public class Api_1_Fvw_Sear_1 extends TestToolkitApplet implements UICCConstants +{ + private FileView UiccFileView = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private byte[] RecValue1 = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08, + (byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + private byte[] RecValue2 = {(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x01,(byte)0x02, + (byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09}; + private byte[] RecValue3 = {(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B, + (byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x01,(byte)0x02,(byte)0x03}; + private byte[] RecValue4 = {(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06}; + private byte[] RecValue5 = {(byte)0x0A,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x0B,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x0C,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x0D,(byte)0x01,(byte)0x02}; + private byte[] RecValue6 = {(byte)0x03,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x02, + (byte)0x01,(byte)0x03,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x02,(byte)0x01}; + + byte testCaseNb = (byte) 0x00; + byte patt[] = null; + short resp[] = null; + short comp[] = null; + byte mode = 0; + short recordNumber = 0; + short searchIndication = 0; + short pattOffset = 0; + short respOffset = 0; + short pattLength = 0; + short respLength = 0; + short nbRecFound = 0; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Sear_1() + { + comp = new short[5]; + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Sear_1 thisApplet = new Api_1_Fvw_Sear_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + // searchRecord + patt = new byte[3]; + resp = new short[4]; + Util.arrayFillNonAtomic(patt, (short)0, (short)patt.length, (byte)0xAA); + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // -- Fixed linear EF + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + + + // ----------------------------------------------------------------- + // Test Case 2 : Simple mode search forward + // ----------------------------------------------------------------- + testCaseNb = 2; + UiccFileView.select((short)UICCTestConstants.FID_EF_LSEA); + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + patt[0] = (byte)0x10; + patt[1] = (byte)0x03; + patt[2] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 4; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)2; + comp[2] = (short)4; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)2; + comp[2] = (short)4; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Simple mode search backward + // ----------------------------------------------------------------- + testCaseNb = 3; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + patt[0] = (byte)0x08; + patt[1] = (byte)0x0A; + patt[2] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 2; + respLength = 2; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + patt = new byte[4]; + patt[0] = (byte)0x08; + patt[1] = (byte)0x09; + patt[2] = (byte)0x0A; + patt[3] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 6; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)1; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + patt = new byte[4]; + patt[0] = (byte)0x08; + patt[1] = (byte)0x09; + patt[2] = (byte)0x0A; + patt[3] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)1; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // --------------------------------------------------------------------------------------------------- + // Test Case 4 : Enhanced Mode, search backward from previous record, start search at offset in record + // --------------------------------------------------------------------------------------------------- + testCaseNb = 4; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0009; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + patt[3] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x03; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0000; + recordNumber = 0; + pattOffset = 0; + pattLength = 5; + respOffset = 2; + respLength = 2; + patt = new byte[6]; + patt[0] = (byte)0x0C; + patt[1] = (byte)0x0D; + patt[2] = (byte)0x0E; + patt[3] = (byte)0x0F; + patt[4] = (byte)0x01; + patt[5] = (byte)0x02; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (byte)0x02; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------------------------------------- + // Test Case 5 : Enhanced Mode, search backward from previous record, start search at value in record + // -------------------------------------------------------------------------------------------------- + testCaseNb = 5; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0810; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt = new byte[4]; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + patt[3] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // 3 readRecord() to set record pointer to record 5 + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)4); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)4); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)4); + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x080E; + recordNumber = 0; + pattOffset = 3; + pattLength = 1; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + patt[3] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x04; + comp[1] = (byte)0x02; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------------------------------------- + // Test Case 6 : Enhanced Mode, search backward from previous given record, start at offset in record + // -------------------------------------------------------------------------------------------------- + testCaseNb = 6; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0000; + recordNumber = 1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 4; + patt = new byte[3]; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x01; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0004; + recordNumber = 6; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)5; + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)2; + if ((nbRecFound == (short)4) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ------------------------------------------------------------------------------------------------- + // Test Case 7 : Enhanced Mode, search backward from previous given record, start at value in record + // ------------------------------------------------------------------------------------------------- + testCaseNb = 7; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x080D; + recordNumber = 1; + pattOffset = 1; + pattLength = 1; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x0E; + patt[1] = (byte)0x0E; + patt[2] = (byte)0x0E; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x01; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0800; + recordNumber = 6; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // --------------------------------------------------------------------------------------- + // Test Case 8 : Enhanced Mode, search forward from next record, start at offset in record + // --------------------------------------------------------------------------------------- + testCaseNb = 8; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0003; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + patt[0] = (byte)0x00; + patt[1] = (byte)0x0A; + patt[2] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (short) 3; + comp[3] = (short) 4; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0003; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 0; + respLength = 4; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short) 4; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------------------------- + // Test Case 9 : Enhanced Mode, search forward from next record, start at value in record + // -------------------------------------------------------------------------------------- + testCaseNb = 9; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0804; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0801; + recordNumber = 0; + pattOffset = 2; + pattLength = 1; + respOffset = 0; + respLength = 4; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short) 5; + comp[1] = (short) 6; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ---------------------------------------------------------------------------------------------- + // Test Case 10 : Enhanced Mode, search forward from next given record, start at offset in record + // ---------------------------------------------------------------------------------------------- + testCaseNb = 10; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x0007; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 1; + respLength = 3; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)3; + comp[2] = (short)4; + comp[3] = (short)5; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x000C; + recordNumber = 3; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x03; + patt[1] = (byte)0x02; + patt[2] = (byte)0x01; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x06; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // --------------------------------------------------------------------------------------------- + // Test Case 11 : Enhanced Mode, search forward from next given record, start at value in record + // --------------------------------------------------------------------------------------------- + testCaseNb = 11; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x080D; + recordNumber = 5; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x080C; + recordNumber = 5; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x05; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ---------------------------------------------------------------------------- + // Test Case 12 : Simple mode, total number of found patterns exceed response[] + // ---------------------------------------------------------------------------- + testCaseNb = 12; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)1; + comp[1] = (short)2; + comp[2] = (short)3; + comp[3] = (short)4; + if ((nbRecFound == (short)4) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + resp = new short[5]; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)1; + comp[1] = (short)2; + comp[2] = (short)3; + comp[3] = (short)4; + if ((nbRecFound == (short)4) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 13 : Invalid mode + // ----------------------------------------------------------------- + testCaseNb = 13; + try + { + // searchRecord + mode = (byte)0x14; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.INVALID_MODE) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 14 : Pattern array is null + // ----------------------------------------------------------------- + testCaseNb = 14; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, null, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 15 : Response array is null + // ----------------------------------------------------------------- + testCaseNb = 15; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, null, respOffset, respLength); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 16 : pattOffset<0 + // ----------------------------------------------------------------- + testCaseNb = 16; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = -1; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 17 : pattLength<0 + // ----------------------------------------------------------------- + testCaseNb = 17; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = -1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 18 : respOffset<0 + // ----------------------------------------------------------------- + testCaseNb = 18; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = -1; + respLength = 4; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 19 : respLength<0 + // ----------------------------------------------------------------- + testCaseNb = 19; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = -1; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 20 : PattOffset + pattLength > patt[] + // ----------------------------------------------------------------- + testCaseNb = 20; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 2; + respOffset = 1; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 21 : respOffset + respLength > resp[] + // ----------------------------------------------------------------- + testCaseNb = 21; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = 3; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 22 : recordNum < 0 + // ----------------------------------------------------------------- + testCaseNb = 22; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = -1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.RECORD_NOT_FOUND) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 23 : RecordNum > total number of file records + // ----------------------------------------------------------------- + testCaseNb = 23; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 7; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.RECORD_NOT_FOUND) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 24 : pattlength > record length + // ----------------------------------------------------------------- + testCaseNb = 24; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + patt = new byte[16]; + Util.arrayFillNonAtomic(patt, (short)0, (short)patt.length, (byte)0x55); + recordNumber = 3; + pattOffset = 0; + pattLength = 16; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x000E; + recordNumber = 3; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + patt = new byte[3]; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 25 : Wrong file structure + // ----------------------------------------------------------------- + testCaseNb = 25; + try + { + // Select EF TDAC + UiccFileView.select((short)UICCTestConstants.FID_EF_TDAC); + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.COMMAND_INCOMPATIBLE) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 26 : Security status not satisfied + // ----------------------------------------------------------------- + testCaseNb = 26; + try + { + // Select EF LNR + UiccFileView.select((short)UICCTestConstants.FID_EF_LNR); + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 27 : File deactivated + // ----------------------------------------------------------------- + testCaseNb = 27; + try + { + // Select EF LARU and deactivate it + UiccFileView.select((short)UICCTestConstants.FID_EF_LARU); + UiccFileView.deactivateFile(); + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.REF_DATA_INVALIDATED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + // Re active EF LARU + UiccFileView.activateFile(); + + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // -- Cyclic EF + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + + + // ----------------------------------------------------------------- + // Test Case 28 : Simple mode search forward + // ----------------------------------------------------------------- + testCaseNb = 28; + try + { + // Select EF CSEA + UiccFileView.select((short)UICCTestConstants.FID_EF_CSEA); + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x10; + patt[1] = (byte)0x03; + patt[2] = (byte)0x04; + resp = new short[5]; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)3) + { + comp[2] = (short)2; + comp[3] = (short)4; + comp[4] = (short)1; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)2) + { + comp[2] = (short)2; + comp[3] = (short)4; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + + // Update record in previous mode to set pointer 1 to previous record 6 + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue6, (short)0, (short)RecValue6.length); + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (short)2; + comp[3] = (short)3; + comp[4] = (short)5; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 29 : Simple mode search backward + // ----------------------------------------------------------------- + testCaseNb = 29; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + recordNumber = 3; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 4; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)3) + { + comp[1] = (short)3; + comp[2] = (short)2; + comp[3] = (short)5; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)2) + { + comp[1] = (short)3; + comp[2] = (short)2; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 30 : Enhanced mode, search forward, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 30; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0009; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (short)4; + comp[3] = (short)5; + comp[4] = (short)6; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 31 : Enhanced mode, search forward, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 31; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0810; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 32 : Enhanced mode, search forward given record, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 32; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x0005; + recordNumber = 3; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)5) + { + comp[0] = (short)3; + comp[1] = (short)4; + comp[2] = (short)5; + comp[3] = (short)6; + comp[4] = (short)1; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)4) + { + comp[0] = (short)3; + comp[1] = (short)4; + comp[2] = (short)5; + comp[3] = (short)6; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 33 : Enhanced mode, search forward given record, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 33; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x0805; + recordNumber = 6; + pattOffset = 0; + pattLength = 2; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x0E; + patt[1] = (byte)0x0F; + patt[2] = (byte)0x00; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)2) + { + comp[0] = (short)2; + comp[1] = (short)4; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)0) + { + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + + // 5 Update record in previous mode to set pointer 1 its initial value + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue5, (short)0, (short)RecValue5.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue4, (short)0, (short)RecValue4.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue3, (short)0, (short)RecValue3.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue2, (short)0, (short)RecValue2.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue1, (short)0, (short)RecValue1.length); + + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 34 : Enhanced mode, search backward, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 34; + try + { + patt = new byte[15]; + // 5 readRecord() to set record pointer to record 6 + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0003; + recordNumber = 0; + pattOffset = 0; + pattLength = 2; + respOffset = 3; + respLength = 2; + patt[0] = (byte)0x02; + patt[1] = (byte)0x01; + patt[2] = (byte)0x00; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)1) + { + comp[3] = (short)6; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)0) + { + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 35 : Enhanced mode, search backward, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 35; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0801; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)5; + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)2; + comp[4] = (short)1; + if ((nbRecFound == (short)5) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 36 : Enhanced mode, search backward given record, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 36; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0003; + recordNumber = 5; + pattOffset = 0; + pattLength = 2; + respOffset = 3; + respLength = 2; + patt[0] = (byte)0x02; + patt[1] = (byte)0x01; + patt[2] = (byte)0x00; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)1) + { + comp[3] = (short)6; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)0) + { + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 37 : Enhanced mode, search backward given record, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 37; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0801; + recordNumber = 3; + pattOffset = 1; + pattLength = 2; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)5) + { + comp[0] = (short)3; + comp[1] = (short)2; + comp[2] = (short)1; + comp[3] = (short)5; + comp[4] = (short)4; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)3) + { + comp[0] = (short)3; + comp[1] = (short)2; + comp[2] = (short)1; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + + private void shortArrayFill(short buff[], short buffOffset, short fillLength, short value) + { + for (short i = buffOffset; i < (short)(fillLength + buffOffset); i++) + { + buff[i] = value; + } + } + + private byte shortArrayCompare(short buff1[], short buff1Offset, short buff2[], short buff2Offset, short compLength) + { + byte ret = 0; + + for (byte i = 0; ((i < compLength) && (ret == 0)); i++) + { + byte j = (byte)(i+buff1Offset); + byte k = (byte)(i+buff2Offset); + if (buff1[j] != buff2[k]) + ret = 1; + } + return ret; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/Test_Api_1_Fvw_Sear.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/Test_Api_1_Fvw_Sear.java new file mode 100644 index 0000000000000000000000000000000000000000..03241f59f6ab33087205a2c62efcf3a9fe372fab --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/Test_Api_1_Fvw_Sear.java @@ -0,0 +1,97 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_sear; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Sear extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_sear"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Sear() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "25" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..37d8b9af5368ee73a4a7d90e6bc57675a259020f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_sear.Api_1_Fvw_Sear_1 +uicc.test.access.api_1_fvw_sear +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/javacard/api_1_fvw_sear.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/javacard/api_1_fvw_sear.cap new file mode 100644 index 0000000000000000000000000000000000000000..75ee8846ac34aed4458e63faa1b7258d5bb4bcb4 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_sear/javacard/api_1_fvw_sear.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/Api_1_Fvw_Slctb_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/Api_1_Fvw_Slctb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..af43ce4e9e307e64b9dc0d65a7449df71eac9acd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/Api_1_Fvw_Slctb_1.java @@ -0,0 +1,183 @@ +//----------------------------------------------------------------------------- +// Api_1_Fvw_Slctb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_slctb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.test.util.* ; + + +public class Api_1_Fvw_Slctb_1 extends TestToolkitApplet{ + + private final byte SFI_EFTnr = 0x01; + private final byte SFI_EFTnu = 0x02; + private final byte SFI_EFTaru = 0x03; + private final byte SFI_EFCnu = 0x05; + + byte[] data = new byte[4]; + byte[] resp = new byte[4]; + + short fileOffset; + short respOffset; + short respLength; + + + AID AidADF1; + + private FileView theUiccView; + private FileView theFileView; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Slctb_1(){ + + UICCTestConstants objectConstants = new UICCTestConstants(); + AidADF1 = new AID(objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Api_1_Fvw_Slctb_1 thisApplet = new Api_1_Fvw_Slctb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event){ + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + + + //test case 1: Selection possiblities, UICC file system + try { + theUiccView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(SFI_EFTnr); //EFTNR + theUiccView.select(SFI_EFTnu); //EFTNU + theUiccView.select(SFI_EFCnu); //EFCNU + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 2: Selection possiblities, ADF1 + + try { + theFileView = UICCSystem.getTheFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + theFileView.select(UICCTestConstants.FID_DF_TEST); + theFileView.select(SFI_EFTnr); //EFTNR + theFileView.select(SFI_EFTnu); //EFTNU + theFileView.select(SFI_EFCnu); //EFCNU + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 3: Current EF it self can be selected + + try { + theUiccView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(SFI_EFTnr); //EFTNR + theUiccView.select(SFI_EFTnr); //EFTNR + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x03; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 4: FILE_NOT_FOUND + + try { + theUiccView.select((byte) 0x55); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x04; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 5: File context changed + + fileOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + try { + + data[0] = (byte) 0xFF; + data[1] = (byte) 0xFF; + data[2] = (byte) 0xFF; + theUiccView.select(SFI_EFTaru); //EFTARU + theUiccView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + if (Util.arrayCompare(data, (short)0, resp, (short)0, (short)3) == 0) { + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x05; + reportTestOutcome(bTestCaseNb, bRes); + + try { + + data[0] = (byte) 0x55; + data[1] = (byte) 0x55; + data[2] = (byte) 0x55; + theUiccView.select(SFI_EFTnu); //EFTNU + theUiccView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + if (Util.arrayCompare(data, (short)0, resp, (short)0, (short)3) == 0) { + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome(bTestCaseNb, bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/Test_Api_1_Fvw_Slctb.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/Test_Api_1_Fvw_Slctb.java new file mode 100644 index 0000000000000000000000000000000000000000..7022d66086f87f47ba0562c661a8a6d04a227b42 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/Test_Api_1_Fvw_Slctb.java @@ -0,0 +1,87 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_slctb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Slctb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_slctb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Slctb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Selecction possibilities, UICC file system */ + /** Testcase 2 Selection possiblities, ADF1 */ + /** Testcase 3 Current EF itself can be selected */ + /** Testcase 4 FILE_NOT_FOUND */ + /** Testcase 5 File context changed */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..20bbef3ad2239cd73a99031625c9859a26d99ade --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_slctb.Api_1_Fvw_Slctb_1 +uicc.test.access.api_1_fvw_slctb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/javacard/api_1_fvw_slctb.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/javacard/api_1_fvw_slctb.cap new file mode 100644 index 0000000000000000000000000000000000000000..cb2e9973c43cf92ae6647261880f9014c85daaba Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb/javacard/api_1_fvw_slctb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/Api_1_Fvw_Slctb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/Api_1_Fvw_Slctb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ec1efd7d58aac2e87fd95f06ea36cf145b5be54a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/Api_1_Fvw_Slctb_Bss_1.java @@ -0,0 +1,811 @@ +//----------------------------------------------------------------------------- +// Api_1_Fvw_Slctb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_slctb_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.test.util.* ; + + + +public class Api_1_Fvw_Slctb_Bss_1 extends TestToolkitApplet{ + + public static byte[] FDescriptor = {(byte) 0x82, (byte) 0xFF, (byte) 0xFF, (byte) 0x21, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; + public static byte[] FId_MF = {(byte) 0x83, (byte) 0x02, (byte) 0x3F, (byte) 0x00}; + public static byte[] FId_DFTelecom = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x10}; + public static byte[] FId_DFTest = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x4A}; + public static byte[] FId_EFTaru = {(byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x03}; + public static byte[] FId_EFLaru = {(byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x0C}; + public static byte[] DFName = {(byte) 0x84, (byte) 0x10, (byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + public static byte[] lifeCycle = {(byte) 0x8A, (byte) 0x01, (byte) 0x05}; + public static byte[] fileSize = {(byte) 0x80, (byte) 0x02, (byte) 0x01, (byte) 0x04}; + public static byte[] secAttributesLARR1a = {(byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01}; + public static byte[] secAttributesLARR1b = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01}; + public static byte[] secAttributesLARR1c = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x01}; + public static byte[] secAttributesTARR3a = {(byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x03}; + public static byte[] secAttributesTARR3b = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x03}; + public static byte[] secAttributesTARR3c = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x03}; + + public static byte[] fcp; + public static byte[] normalBuffer = new byte[132]; + public static byte[] nullBuffer = null; + + + byte[] resp = new byte[4]; + byte[] data = new byte[4]; + + short dataOffset; + short dataLength; + short fileOffset; + short respOffset; + short respLength; + short recNumber; + byte mode; + short recOffset; + + AID AidADF1; + + private FileView theUiccView; + private FileView theFileView; + + private short findTLV (byte tag, byte[] buffer, short offset) { + + short index=1; + short len; + + index = (short)(index + offset); + + if (buffer[(byte)index]==(byte)0x81) { + index++; + len = (short) (buffer[(byte)index] + index + (short)1); + }else if (buffer[(byte)index]==(byte)0x82){ + index = (short)(index + (short)2); + len = (short) (Util.getShort(buffer,(byte)index) + index); + } + else{ + len = (short) (buffer[(byte)index] + index + (short)1); + } + + + index++; + + while (index < len) { + + if ( (buffer[(byte)index] & (byte)0x7F) == (tag & (byte)0x7F) ) { + return(index); + } + index = (short) (index + (short) buffer[(byte)(index + (byte)1)] + (short)2); + } + + return(0); + + } + + + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Slctb_Bss_1(){ + + UICCTestConstants objectConstants = new UICCTestConstants(); + AidADF1 = new AID(objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Api_1_Fvw_Slctb_Bss_1 thisApplet = new Api_1_Fvw_Slctb_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event){ + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + EnvelopeHandler envHdlr; + short fcpOffset = 0; + short fcpLength = 0; + short result = 0; + + + short FDOffset = (short)2; //offset of File descriptor TLV in fcp + short FDByteOffset = (short)4; //offset of File descriptor byte in fcp + short FIdOffset = (short)6; //offset of File Identifier TLV in fcp + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TEST CASE 0:Get a FileView object, UICC file system + *----------------------------------------------------------------*/ + theUiccView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + /*------------------------------------------------------------------ + * TEST CASE 1: Select EFTARU in MF (Transparent EF) + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + result = theUiccView.select(UICCTestConstants.FID_EF_TARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x41; + if ((result >= 19) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)4)==0) + &&(Util.arrayCompare(FId_EFTaru, (short)0, fcp, FIdOffset, (short)FId_EFTaru.length)==0)) { + + bRes = true; + } + + fcpOffset=findTLV((byte)0x8A, fcp, (short)0);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare(lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + fcpOffset=findTLV((byte)0x80, fcp, (short)0);//file size + if ((fcpOffset !=0) && (Util.arrayCompare(fileSize, (short)0, fcp, fcpOffset, (short)fileSize.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 2: Select EFTaru in MF (Transparent EF) + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 7; + result = theUiccView.select(UICCTestConstants.FID_EF_TARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x41; + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)4)==0)) { + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome(bTestCaseNb, bRes); + + + + /*------------------------------------------------------------------ + * TEST CASE 3: Select DF Test in MF + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + result = theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result >= 17) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)4)==0) + &&(Util.arrayCompare(FId_DFTest, (short)0, fcp, FIdOffset, (short)FId_DFTest.length)==0)) { + + bRes = true; + } + fcpOffset=findTLV((byte)0x8A, fcp, (short)0);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare(lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x03; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 4: Select EF CARU in DF Test(Cyclic EF) + *----------------------------------------------------------------*/ + bRes = false; + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 11; + result = theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDOffset++; + } + FDescriptor[1] = 0x05; + FDescriptor[2] = 0x46; + FDescriptor[4] = 0x00;// record + FDescriptor[5] = 0x03;// length + FDescriptor[6] = 0x02;// number of records + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)7)==0)) { + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x04; + reportTestOutcome(bTestCaseNb, bRes); + + + + + /*------------------------------------------------------------------ + * TEST CASE 5: Select ADF1 + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 5; + fcpLength = 127; + theFileView = UICCSystem.getTheFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + result = theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + + fcp[0]=fcp[1]=fcp[2]=fcp[3]=fcp[4]=0x00; + + if (fcp[(byte)(1 + fcpOffset)] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result >= 27) + &&(fcp[0]==(byte)0x00) && (fcp[1]==(byte)0x00) && (fcp[2]==(byte)0x00) && (fcp[3]==(byte)0x00) && (fcp[4]==(byte)0x00) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, (short)(FDOffset + fcpOffset), (short)4)==0)) { + + bRes = true; + } + fcpOffset=findTLV((byte)0x84, fcp, fcpOffset); //DF Name + if ((fcpOffset !=0) && (Util.arrayCompare(DFName, (short)0, fcp, fcpOffset, (short)DFName.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + fcpOffset = 5; + fcpOffset=findTLV((byte)0x8A, fcp, fcpOffset);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare(lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x05; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 6: Select MF + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 11; + result = theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[(byte)(FDByteOffset+fcpOffset)]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, (short) (fcpOffset+FDOffset), (short)4)==0) + &&(Util.arrayCompare(FId_MF, (short)0, fcp, (short) (fcpOffset+FIdOffset), (short)FId_MF.length)==0)) { + + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 7: Select DF TELECOM in MF + *----------------------------------------------------------------*/ + bRes = false; + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcp[0] = fcp[1] = (byte)0x05; + fcpOffset = 2; + fcpLength = 13; + result = theUiccView.select(UICCConstants.FID_DF_TELECOM, fcp, fcpOffset, fcpLength); + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[(byte)(FDByteOffset+fcpOffset)]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result == fcpLength) + &&(fcp[0]==(byte)0x05) && (fcp[1]==(byte)0x05) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, (short) (fcpOffset+FDOffset), (short)4)==0) + &&(Util.arrayCompare(FId_DFTelecom, (short)0, fcp, (short) (fcpOffset+FIdOffset), (short)FId_DFTelecom.length)==0)) { + + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x07; + reportTestOutcome(bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 8: Select EF LARU in DF TEST (Linear FixedEF) + *----------------------------------------------------------------*/ + bRes = false; + try { + FDOffset = (short)2; + FIdOffset = (short)9; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 14; + theUiccView.select(UICCTestConstants.FID_DF_TEST); + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDOffset++; + FIdOffset++; + } + FDescriptor[1] = 0x05; + FDescriptor[2] = 0x42; + FDescriptor[4] = 0x00;// record + FDescriptor[5] = 0x04;// length + FDescriptor[6] = 0x02;// number of records + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)7)==0) + &&(Util.arrayCompare(FId_EFLaru, (short)0, fcp, (short) FIdOffset, (short)FId_EFLaru.length)==0)) { + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x08; + reportTestOutcome(bTestCaseNb, bRes); + + + + /*------------------------------------------------------------------ + * TEST CASE 9: fcp is null + *----------------------------------------------------------------*/ + try { + fcp = nullBuffer; + fcpOffset = 0; + fcpLength = 15; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (NullPointerException npe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x09; + reportTestOutcome(bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 10: fcpOffset < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = -1; + fcpLength = 15; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0A; + reportTestOutcome(bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 11: fcpLength < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = -1; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0B; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 12: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 115; + fcpLength = 18; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0C; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 13: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = (short) (fcp.length+1); + fcpLength = 0; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0D; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 14: Selection possiblities + *----------------------------------------------------------------*/ + + + try { + fcpOffset = 0; + + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + + theUiccView.select(UICCTestConstants.FID_EF_UICC, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_CNU, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_SUB_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0E; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 15: EF not selected after MF/DF selection + *----------------------------------------------------------------*/ + + try { + + fileOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCConstants.FID_EF_ICCID, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + + theUiccView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x0F; + reportTestOutcome(bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 16: No selection of non-reachable file + *----------------------------------------------------------------*/ + + try { + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x10; + reportTestOutcome(bTestCaseNb, bRes); + + /*--------------------------------------------------------------------- + * TEST CASE 17: No record is selected afterselecting linear fixed EF + *--------------------------------------------------------------------*/ + + try { + + recNumber = (short) 0; + mode = (byte) UICCConstants.REC_ACC_MODE_CURRENT; + recOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 4; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.RECORD_NOT_FOUND); + } + bTestCaseNb = 0x11; + reportTestOutcome(bTestCaseNb, bRes); + + + /*--------------------------------------------------------------------- + * TEST CASE 18: Record pointer in selected cyclic EF + *--------------------------------------------------------------------*/ + bRes = false; + + recNumber = (short) 0; + recOffset = (short) 0; + dataOffset = (short) 0; + dataLength = (short) 3; + respOffset = (short) 0; + respLength = (short) 3; + + try { + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + + data[0] = 1; + data[1] = 2; + data[2] = 3; + mode = UICCConstants.REC_ACC_MODE_PREVIOUS; + theUiccView.updateRecord(recNumber, mode, recOffset, data, dataOffset, dataLength); + + theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + + mode = UICCConstants.REC_ACC_MODE_PREVIOUS; + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + + if (Util.arrayCompare(data, (short)0, resp, (short)0, (short)3)==0) { + bRes = true; + } + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x12; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 19: EF not selected after ADF/DF selection + *----------------------------------------------------------------*/ + + try { + + fileOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_EF_UICC, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + + theFileView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x13; + reportTestOutcome(bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 20: Reselection + *----------------------------------------------------------------*/ + + + try { + + //ADF FileView + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + + //UICC FileView + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x14; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 21: Security attributes + *----------------------------------------------------------------*/ + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //ADF FileView + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_EF_LARR1, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesLARR1a, (short)0, fcp, fcpOffset, (short)secAttributesLARR1a.length)==0) + ||(Util.arrayCompare(secAttributesLARR1b, (short)0, fcp, fcpOffset, (short)secAttributesLARR1b.length)==0) + ||(Util.arrayCompare(secAttributesLARR1c, (short)0, fcp, fcpOffset, (short)secAttributesLARR1c.length)==0)) ){ + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x15; + reportTestOutcome(bTestCaseNb, bRes); + + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //UICC FileView + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TARR3, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesTARR3a, (short)0, fcp, fcpOffset, (short)secAttributesTARR3a.length)==0) + ||(Util.arrayCompare(secAttributesTARR3b, (short)0, fcp, fcpOffset, (short)secAttributesTARR3b.length)==0) + ||(Util.arrayCompare(secAttributesTARR3c, (short)0, fcp, fcpOffset, (short)secAttributesTARR3c.length)==0)) ){ + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x16; + reportTestOutcome(bTestCaseNb, bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/Test_Api_1_Fvw_Slctb_Bss.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/Test_Api_1_Fvw_Slctb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..13c1af6b28ba854879c21537501144f37f1afc2b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/Test_Api_1_Fvw_Slctb_Bss.java @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_slctb_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Slctb_Bss extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_slctb_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + static final String MF = "3F00"; + static final String DFTEST = "7F4A"; + static final String EFCARU = "6F09"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Slctb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Select EFTARU in MF (Transparent EF) */ + /** Testcase 2 Select EFTaru in MF (Transparent EF) */ + /** Testcase 3 Select DF Test in MF */ + /** Testcase 4 Select EF CARU in DF Test(Cyclic EF) */ + /** Testcase 5 Select ADF1 */ + /** Testcase 6 Select MF */ + /** Testcase 7 Select DF TELECOM in MF */ + /** Testcase 8 Select EF LARU in DF TEST (Linear FixedEF) */ + /** Testcase 9 fcp is null */ + /** Testcase 10 fcpOffset < 0 */ + /** Testcase 11 fcpLength < 0 */ + /** Testcase 12 fcpOffset + fcpLength > fcp.length */ + /** Testcase 13 fcpOffset + fcpLength > fcp.length */ + /** Testcase 14 Selection possiblities */ + /** Testcase 15 EF not selected after MF/DF selection */ + /** Testcase 16 No selection of non-reachable file */ + /** Testcase 17 No record is selected afterselecting linear fixed EF */ + /** Testcase 18 Record pointer in selected cyclic EF */ + /** Testcase 19 EF not selected after ADF/DF selection */ + /** Testcase 20 Reselection */ + /** Testcase 21 Security attributes */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "16CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + //Select EF CARU + test.selectFile(MF); + test.selectFile(DFTEST); + test.selectFile(EFCARU); + test.updateRecord("00", "03", "AAAAAA");//Mode previous + test.updateRecord("00", "03", "555555");//Mode previous + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b23f4fc6044c41730a8b0ea30c9a3557bec58af0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_slctb_bss.Api_1_Fvw_Slctb_Bss_1 +uicc.test.access.api_1_fvw_slctb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/javacard/api_1_fvw_slctb_bss.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/javacard/api_1_fvw_slctb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..c1da56e12e3e5b4567a86483fc52d45e8d3059ac Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slctb_bss/javacard/api_1_fvw_slctb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/Api_1_Fvw_Slcts_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/Api_1_Fvw_Slcts_1.java new file mode 100644 index 0000000000000000000000000000000000000000..918a4596189b4b38980294d5209c858249af3cbb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/Api_1_Fvw_Slcts_1.java @@ -0,0 +1,310 @@ +//----------------------------------------------------------------------------- +// Api_1_Fvw_Slcts_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_slcts; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Api_1_Fvw_Slcts_1 extends TestToolkitApplet{ + + + byte[] data = new byte[4]; + byte[] resp = new byte[4]; + + short recNumber; + byte mode; + short recOffset; + short dataOffset; + short dataLength; + short respOffset; + short respLength; + + AID AidADF1; + + private FileView theUiccView; + private FileView theFileView; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Slcts_1(){ + + UICCTestConstants objectConstants = new UICCTestConstants(); + AidADF1 = new AID(objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Api_1_Fvw_Slcts_1 thisApplet = new Api_1_Fvw_Slcts_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event){ + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + //test case 0: Get a FileView object, UICC file system + theUiccView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + + //test case 1: Selection possiblities + try { + + theUiccView.select(UICCTestConstants.FID_EF_UICC); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_CNU); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_DF_SUB_TEST); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_MF); + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 2: Selection possiblities ADF1 + + try { + + theFileView = UICCSystem.getTheFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + + theFileView.select(UICCTestConstants.FID_EF_UICC); + theFileView.select(UICCTestConstants.FID_DF_TEST); + theFileView.select(UICCTestConstants.FID_EF_CNU); + theFileView.select(UICCTestConstants.FID_EF_TAAA); + theFileView.select(UICCTestConstants.FID_DF_SUB_TEST); + theFileView.select(UICCTestConstants.FID_DF_TEST); + theFileView.select(UICCTestConstants.FID_EF_TAAA); + theFileView.select(UICCTestConstants.FID_DF_TEST); + + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 3: No selection of unreachable file + + theUiccView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + try { + theUiccView.select(UICCTestConstants.FID_EF_CNU); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x03; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_DF_TEST); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x04; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_EF_TAA); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x05; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_EF_CNU); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_DF_SUB_TEST); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x07; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_EF_TAA); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x08; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCConstants.FID_DF_TELECOM); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x09; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 4: Self selection + + try { + + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + + theFileView = UICCSystem.getTheFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + + theFileView.select(UICCTestConstants.FID_ADF); + theFileView.select(UICCTestConstants.FID_ADF); + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0A; + reportTestOutcome(bTestCaseNb, bRes); + + + + //test case 5: EF not selected after MF/DF selection + + recNumber = (short) 1; + mode = (byte) UICCConstants.REC_ACC_MODE_ABSOLUTE; + recOffset = (short) 0; + data[0] = (byte) 0; + data[1] = (byte) 0; + data[2] = (byte) 0; + dataOffset = (short) 0; + dataLength = (short) 3; + + try { + theUiccView.select(UICCTestConstants.FID_MF); + bRes = true; + theUiccView.updateRecord(recNumber, mode, recOffset, data, dataOffset, dataLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x0B; + reportTestOutcome(bTestCaseNb, bRes); + + try { + theUiccView.select(UICCTestConstants.FID_DF_TEST); + bRes = true; + theUiccView.updateRecord(recNumber, mode, recOffset, data, dataOffset, dataLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x0C; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 6: No record is selected after selecting linear fixed EF + + try { + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_LARU); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0D; + reportTestOutcome(bTestCaseNb, bRes); + + recNumber = (short) 0; + mode = (byte) UICCConstants.REC_ACC_MODE_CURRENT; + recOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 4; + + try { + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.RECORD_NOT_FOUND); + } + bTestCaseNb = 0x0E; + reportTestOutcome(bTestCaseNb, bRes); + + + try { + theUiccView.select(UICCTestConstants.FID_EF_CARU); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0F; + reportTestOutcome(bTestCaseNb, bRes); + + recNumber = (short) 0; + mode = (byte) UICCConstants.REC_ACC_MODE_CURRENT; + recOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + try { + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.RECORD_NOT_FOUND); + } + bTestCaseNb = 0x10; + reportTestOutcome(bTestCaseNb, bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/Test_Api_1_Fvw_Slcts.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/Test_Api_1_Fvw_Slcts.java new file mode 100644 index 0000000000000000000000000000000000000000..a1dcc7264455b34401552f598158a0b2d79a0cfb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/Test_Api_1_Fvw_Slcts.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_slcts; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Slcts extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_slcts"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + static final String MF = "3F00"; + static final String DFTEST = "7F4A"; + static final String EFCARU = "6F09"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Slcts() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Selecction possibilities */ + /** Testcase 2 Selection possiblities ADF1 */ + /** Testcase 3 No selection of unreachable file */ + /** Testcase 4 Self selection */ + /** Testcase 5 EF not selected after MF/DF selection */ + /** Testcase 6 No record is selected after selecting linear fixed EF */ + /** Testcase 7 Record pointer in selected cyclic EF */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "10CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + //Select EF CARU + test.selectFile(MF); + test.selectFile(DFTEST); + test.selectFile(EFCARU); + test.updateRecord("00", "03", "AAAAAA");//Mode previous + test.updateRecord("00", "03", "555555");//Mode previous + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..96f2a059c5ac500aa4e9189937e129bac1e052fb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_slcts.Api_1_Fvw_Slcts_1 +uicc.test.access.api_1_fvw_slcts +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/javacard/api_1_fvw_slcts.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/javacard/api_1_fvw_slcts.cap new file mode 100644 index 0000000000000000000000000000000000000000..b4be3e6968cdc444ee37888b0761ef002070143c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_slcts/javacard/api_1_fvw_slcts.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/Api_1_Fvw_Stat_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/Api_1_Fvw_Stat_1.java new file mode 100644 index 0000000000000000000000000000000000000000..de12b666b95a3a8cd1fd644ba0aee0cf7c3c3135 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/Api_1_Fvw_Stat_1.java @@ -0,0 +1,466 @@ +//----------------------------------------------------------------------------- +// Api_1_Fvw_Stat_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_stat; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.test.util.* ; + + +public class Api_1_Fvw_Stat_1 extends TestToolkitApplet { + + public static byte[] FDescriptor = {(byte) 0x82, (byte) 0x02, (byte) 0xFF, (byte) 0x21}; + public static byte[] FId_MF = {(byte) 0x83, (byte) 0x02, (byte) 0x3F, (byte) 0x00}; + public static byte[] FId_DFTelecom = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x10}; + public static byte[] FId_DFTest = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x4A}; + public static byte[] DFName = {(byte) 0x84, (byte) 0x10, (byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + public static byte[] lifeCycle = {(byte) 0x8A, (byte) 0x01, (byte) 0x05}; + public static byte[] secAttributesARR2a = {(byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x02}; + public static byte[] secAttributesARR2b = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x02}; + public static byte[] secAttributesARR2c = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x02}; + public static byte[] secAttributesARR4a = {(byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x04}; + public static byte[] secAttributesARR4b = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x01, (byte) 0x04}; + public static byte[] secAttributesARR4c = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x04}; + + public static byte[] normalBuffer = new byte[127]; + public static byte[] nullBuffer = null; + public static byte[] fcp; + AID AidADF1; + + private FileView theUiccView; + private FileView theFileView; + + /** + * The Constructor register the application for the Event. + */ + public Api_1_Fvw_Stat_1 () { + + UICCTestConstants objectConstants = new UICCTestConstants (); + AidADF1 = new AID (objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + private short findTLV (byte tag, byte[] buffer, short offset) { + + short index=1; + short len; + + index = (short)(index + offset); + + if (buffer[(byte)index]==(byte)0x81) { + index++; + len = (short) (buffer[(byte)index] + index + (short)1); + }else if (buffer[(byte)index]==(byte)0x82){ + index = (short)(index + (short)2); + len = (short) (Util.getShort(buffer,(byte)index) + index); + } + else{ + len = (short) (buffer[(byte)index] + index + (short)1); + } + + + index++; + + while (index < len) { + + if ( (buffer[(byte)index] & (byte)0x7F) == (tag & (byte)0x7F) ) { + return(index); + } + index = (short) (index + (short) buffer[(byte)(index + (byte)1)] + (short)2); + } + + return(0); + + } + + + + public static void install (byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance. + Api_1_Fvw_Stat_1 thisApplet = new Api_1_Fvw_Stat_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register (bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init (); + + thisApplet.obReg.setEvent (EVENT_UNRECOGNIZED_ENVELOPE); + + } + + public void processToolkit (short event) throws ToolkitException { + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + EnvelopeHandler envHdlr; + short fcpOffset = 0; + short fcpLength = 0; + short result = 0; + + + short FDOffset = (short)2; //offset of File descriptor TLV in fcp + short FDByteOffset = (short)4; //offset of File descriptor byte in fcp + short FIdOffset = (short)6; //offset of File Identifier TLV in fcp + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TEST CASE 01: Status of MF + *----------------------------------------------------------------*/ + + theUiccView = UICCSystem.getTheUICCView (JCSystem.CLEAR_ON_RESET); + + try { + fcp = normalBuffer; + fcpOffset = 3; + fcpLength = 11; + fcp[0]=fcp[1]=fcp[2]= (byte)0xCC; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[(byte)(0x01 + fcpOffset)] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[(byte)(FDByteOffset+fcpOffset)]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + if ((result == fcpLength) + &&(Util.arrayCompare (FDescriptor, (short)0, fcp, (short) (fcpOffset+FDOffset), (short)FDescriptor.length)==0) + &&(Util.arrayCompare (FId_MF, (short)0, fcp, (short) (fcpOffset+FIdOffset), (short)FId_MF.length)==0) + &&(fcp[0]==(byte)0xCC) && (fcp[1]==(byte)0xCC) && (fcp[2]==(byte)0xCC)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 02: Status after select EF TARU in MF + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + + theUiccView.select (UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select (UICCTestConstants.FID_EF_TARU, fcp, fcpOffset, fcpLength); + + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[FDByteOffset]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + if ((result >= 19) + &&(Util.arrayCompare (FDescriptor, (short)0, fcp, FDOffset, (short)FDescriptor.length)==0) + &&(Util.arrayCompare (FId_DFTest, (short)0, fcp, FIdOffset, (short)FId_DFTest.length)==0)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Status of DF Telecom + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + theUiccView.select (UICCConstants.FID_DF_TELECOM, fcp, fcpOffset, fcpLength); + + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + if ((result >= 17) + &&(Util.arrayCompare (FId_DFTelecom, (short)0, fcp, FIdOffset, (short)FId_DFTelecom.length)==0)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x03; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Status DF Telecom + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 11; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[FDByteOffset]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + if ((result == fcpLength) + &&(Util.arrayCompare (FDescriptor, (short)0, fcp, FDOffset, (short)FDescriptor.length)==0) + &&(Util.arrayCompare (FId_DFTelecom, (short)0, fcp, FIdOffset, (short)FId_DFTelecom.length)==0)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x04; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Status ADF1 + *----------------------------------------------------------------*/ + bRes = false; + + theFileView = UICCSystem.getTheFileView (AidADF1, JCSystem.CLEAR_ON_RESET); + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + result = theFileView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[FDByteOffset]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + //File Descriptor + if ((result >= 27) && (Util.arrayCompare (FDescriptor, (short)0, fcp, FDOffset, (short)FDescriptor.length)==0)) { + + bRes = true; + } + fcpOffset=findTLV ((byte)0x84, fcp, (short)0);//DF Name + if ((fcpOffset !=0) && (Util.arrayCompare (DFName, (short)0, fcp, fcpOffset, (short)DFName.length)==0)) { + + bRes &= true; + } else { + bRes = false; + } + + fcpOffset=findTLV ((byte)0x8A, fcp, (short)0);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare (lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x05; + reportTestOutcome (bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 06: fcp is null + *----------------------------------------------------------------*/ + try { + fcp = nullBuffer; + fcpOffset = 0; + fcpLength = 34; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (NullPointerException npe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome (bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 07: fcpOffset < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = -1; + fcpLength = 34; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x07; + reportTestOutcome (bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 08: fcpLength < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = -1; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x08; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = (short)(fcp.length - 1); + fcpLength = 15; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x09; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 10: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = (short)(fcp.length+1); + fcpLength = 0; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0A; + reportTestOutcome (bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 11: Security attributes + *----------------------------------------------------------------*/ + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //ADF FileView + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_DF_ARR2, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesARR2a, (short)0, fcp, fcpOffset, (short)secAttributesARR2a.length)==0) + ||(Util.arrayCompare(secAttributesARR2b, (short)0, fcp, fcpOffset, (short)secAttributesARR2b.length)==0) + ||(Util.arrayCompare(secAttributesARR2c, (short)0, fcp, fcpOffset, (short)secAttributesARR2c.length)==0)) ) { + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0B; + reportTestOutcome(bTestCaseNb, bRes); + + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //UICC FileView + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_ARR4, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesARR4a, (short)0, fcp, fcpOffset, (short)secAttributesARR4a.length)==0) + ||(Util.arrayCompare(secAttributesARR4b, (short)0, fcp, fcpOffset, (short)secAttributesARR4b.length)==0) + ||(Util.arrayCompare(secAttributesARR4c, (short)0, fcp, fcpOffset, (short)secAttributesARR4c.length)==0)) ) { + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0C; + reportTestOutcome(bTestCaseNb, bRes); + + + + } // end if + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/Test_Api_1_Fvw_Stat.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/Test_Api_1_Fvw_Stat.java new file mode 100644 index 0000000000000000000000000000000000000000..64ec5117aa7357029da0b99acf5b1314c6014e18 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/Test_Api_1_Fvw_Stat.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_stat; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Fvw_Stat extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_stat"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Stat() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Status of MF */ + /** Testcase 2 Status after select EF TARU in MF */ + /** Testcase 3 Status of DF Telecom */ + /** Testcase 4 Status DF Telecom */ + /** Testcase 5 Status ADF1 */ + /** Testcase 6 fcp is null */ + /** Testcase 7 fcpOffset < 0 */ + /** Testcase 8 fcpLength < 0 */ + /** Testcase 9 fcpOffset + fcpLength > fcp.length */ + /** Testcase 10 fcpOffset + fcpLength > fcp.length */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..34d03f4721127b72f0677861f449b9d50dc1baa6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_stat.Api_1_Fvw_Stat_1 +uicc.test.access.api_1_fvw_stat +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/javacard/api_1_fvw_stat.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/javacard/api_1_fvw_stat.cap new file mode 100644 index 0000000000000000000000000000000000000000..efff8da701f35857918b4cff467934402109729c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_stat/javacard/api_1_fvw_stat.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/Api_1_Fvw_Updb_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/Api_1_Fvw_Updb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b864414caa0df2e88d61859c67ed4fef9decd557 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/Api_1_Fvw_Updb_1.java @@ -0,0 +1,387 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Updb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_updb; + +import javacard.framework.*; +import uicc.access.*; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_updb + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_1_Fvw_Updb_1 extends TestToolkitApplet implements UICCConstants +{ + private FileView UiccFileView = null; + + final short DATA_BUFFER_LENGTH = (short)0x14; + + byte[] data = new byte[DATA_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[DATA_BUFFER_LENGTH]; + byte[] resp = new byte[DATA_BUFFER_LENGTH]; + + private short respOffset; + private short respLength; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Updb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Updb_1 thisApplet = new Api_1_Fvw_Updb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short dataOffset = 0; + short dataLength = 10; + short fileOffset = 0; + + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0); + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*----------------------------------------------------------------------------------- + * TEST CASE 01: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + bRes = false; + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + try { + data[0] = (byte)0x55; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 02: Update transparent file at a given offset + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + try { + + fileOffset = (short)0x03; + dataOffset = (short)0; + dataLength = (short)1; + + // Initialise data buffer + data[0] = (byte)0x55; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + // Read the updated file + respOffset = (short)0; + respLength = (short)1; + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0); + UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + // Initialise the compare buffer and check the readbinary() result + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + compareBuffer[0] = (byte)0x55; + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: fileOffset = 254 + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + fileOffset = (short)0xFE; + dataOffset = 0; + dataLength = 3; + data[0] = (byte)0x55; + data[1] = (byte)0xAA; + data[2] = (byte)0x66; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + // Read the updated file + respOffset = (short)0; + respLength = (short)3; + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0); + UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + // Initialise the compare buffer and check the readbinary() result + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + compareBuffer[0] = (byte)0x55; + compareBuffer[1] = (byte)0xAA; + compareBuffer[2] = (byte)0x66; + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Errorcase, fileOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + fileOffset = (short)-1; + dataOffset = 0; + dataLength = 10; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Errorcase, fileOffset + dataLength > EF length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + fileOffset = (short)259; + dataOffset = 0; + dataLength = 2; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 06: Errorcase, data is null + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + fileOffset = 0; + dataOffset = 0; + dataLength = 10; + UiccFileView.updateBinary(fileOffset, null, dataOffset, dataLength); + bRes = false; + } + catch (NullPointerException npe) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 07: Errorcase, dataOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + fileOffset = 0; + dataOffset = (short)-1; + dataLength = 10; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 08: Errorcase, dataLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + fileOffset = 0; + dataOffset = 0; + dataLength = (short)-1; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: Errorcase, dataOffset + dataLength > data.Length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + fileOffset = 0; + dataOffset = 0x0A; + dataLength = 0x0B; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Errorcase, EF is not transparent + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + fileOffset = 0; + dataOffset = 0; + dataLength = 1; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Errorcase, Access condition not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TNU); + + fileOffset = 0; + dataOffset = 0; + dataLength = 1; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Errorcase, EF is invalidated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_TNR); + UiccFileView.deactivateFile(); + + try { + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + + reportTestOutcome(testCaseNb,bRes); + + /*---------------------------------------------------------------------------------- + * Reset the file content + *---------------------------------------------------------------------------------*/ + fileOffset = (short)0x00; + dataOffset = (short)0; + + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + // Initialise data buffer + byte[] toto = new byte[0x0104]; + Util.arrayFillNonAtomic(toto,(short)0,(short)toto.length,(byte)0xFF); + // Reset the file content + UiccFileView.updateBinary(fileOffset, toto, dataOffset, (short)toto.length); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/Test_Api_1_Fvw_Updb.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/Test_Api_1_Fvw_Updb.java new file mode 100644 index 0000000000000000000000000000000000000000..85f040f513bf2b0d616294ecd90700d7359cc40b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/Test_Api_1_Fvw_Updb.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Fvw_Updb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_updb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_updb + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_1_Fvw_Updb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_updb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Updb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession("0101"); + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..74e0064c320d42812d99cbba75e5e91a502fa3ac --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_updb.Api_1_Fvw_Updb_1 +uicc.test.access.api_1_fvw_updb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/javacard/api_1_fvw_updb.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/javacard/api_1_fvw_updb.cap new file mode 100644 index 0000000000000000000000000000000000000000..35cd26670260922dca85a39a56336c8c98158d4c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updb/javacard/api_1_fvw_updb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/Api_1_Fvw_Updr_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/Api_1_Fvw_Updr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f294c3362773217a9aa51b9690c530c6ef9bada7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/Api_1_Fvw_Updr_1.java @@ -0,0 +1,852 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Updr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_updr; + +import javacard.framework.*; +import uicc.access.*; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_updr + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_1_Fvw_Updr_1 extends TestToolkitApplet implements UICCConstants +{ + private FileView UiccFileView = null; + + final short DATA_BUFFER_LENGTH = (short)0x14; + + byte[] data = new byte[DATA_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[DATA_BUFFER_LENGTH]; + byte[] respBuffer = new byte[DATA_BUFFER_LENGTH]; + + /** + * Constructor of the applet + */ + public Api_1_Fvw_Updr_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Fvw_Updr_1 thisApplet = new Api_1_Fvw_Updr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short dataOffset = 0; + short dataLength = 0; + short fileOffset = 0; + short recOffset = 0; + byte recNumber = 0; + short respOffset = 0; + short respLength = 0; + + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*----------------------------------------------------------------------------------- + * TEST CASE 01: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + recNumber = 1; + dataOffset = 0; + dataLength = 0x0A; + + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + /*------------------------------------------------------------------ + * TEST CASE 02: Update Absolute linear fixed file + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Test case 1.1: Record pointer not set + recNumber = 2; + recOffset = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)dataLength,(byte)0x11); + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0); + Util.arrayFillNonAtomic(data,(short)0,(short)dataLength,(byte)0x11); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + // Read the updated file in ABSOLUTE Mode + respLength = (short)4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(data, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Update current linear fixed EF + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + recNumber = 0; + recOffset = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0x00); + + // Set the record pointer to record 1 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + // Call the updateRecord() method in CURRENT mode + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0x22); + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + + // Read the updated file in CURRENT Mode + respLength = (short)4; + // Initialise respBuffer and compareBuffer + Util.arrayFillNonAtomic(respBuffer,(short)0,(short)respBuffer.length,(byte)0x00); + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x22); + + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*---------------------------------------------------------------------------- + * TEST CASE 04: Update next from a linear fixed file, record pointer not set + *----------------------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Select EF LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x33); + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x33); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Update next from linear fixed EF,record pointer set + *------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x44); + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x44); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------------------- + * TEST CASE 06: Update next linear fixed file, no more record + *-------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + bRes = false; + } + catch(UICCException e) + { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*---------------------------------------------------------------------------------- + * TEST CASE 07: Update previous from a linear fixed file, record pointer not set + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Select linear fixed file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x66); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x66); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*---------------------------------------------------------------------------------- + * TEST CASE 08: Update previous from a linear fixed file, record pointer not set + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x77); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x77); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: Update previous, no more record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x77); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + } + catch(UICCException e) + { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Update previous from cylic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x03; + + // Select cyclic file EF CARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0x00); + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0xFF); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0x00); + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0xFF); + + // Call the updateRecord() method + recOffset = 0; + respLength = 3; + respOffset = 0; + Util.arrayFillNonAtomic(respBuffer,(short)0,(short)respBuffer.length,(byte)0x00); + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Update linear fixed file in ABSOLUTE mode beyond record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + try { + recNumber = (short)-1; + dataOffset = 0; + dataLength = 0x04; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method with recNumber set to -1 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch(Exception e) { + bRes = false; + } + + try { + recNumber = (short)3; + dataOffset = 0; + dataLength = 0x04; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method with recNumber set to 3 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch(Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Update linear fixed file in CURRENT mode, record pointer not set + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x04; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch(Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 13: recOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0D; + bRes = false; + try { + recNumber = (short)1; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)-1; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method with recOffset set to -1 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch(Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 14: recOffset + dataLength > record.length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0E; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)1; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)2; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 15: Invalid mode, linear fixed file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0F; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)0; + // Call the updateRecord() method with mode set to 1 + UiccFileView.updateRecord(recNumber,(byte)1,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)0; + // Call the updateRecord() method with mode set to 5 + UiccFileView.updateRecord(recNumber,(byte)5,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 16: Invalid mode cyclic file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x10; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0); + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode NEXT + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes = ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode CURRENT, recNumber set to 0 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)2; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode ABSOLUTE, recNumber set to 2 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode set to 5, recNumber set to 0 + UiccFileView.updateRecord(recNumber,(byte)5,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 17: data is null + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x11; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = 1; + dataOffset = 0; + dataLength = 4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,null,dataOffset,dataLength); + bRes = false; + } + catch(NullPointerException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 18: dataOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x12; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = 1; + dataOffset = (short)-1; + dataLength = 4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 19: dataLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x13; + bRes = false; + + try { + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)-1; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 20: dataOffset + dataLength > data.length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x14; + bRes = false; + + try { + recNumber = 1; + dataOffset = (short)18; + dataLength = 4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 21: EF is neither cylic or linear fixed + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x15; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + + try { + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 22: Access not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x16; + bRes = false; + + // Select cylic file, Update access set to NEV + UiccFileView.select(UICCTestConstants.FID_EF_CNU); + + try { + recNumber = 0; + dataOffset = (short)0; + dataLength = (short)3; + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + // Select linear fixed file, Update access set to NEV + UiccFileView.select(UICCTestConstants.FID_EF_LNU); + + try { + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(UICCException e){ + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 23: EF is deactivated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x17; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CNR); + UiccFileView.deactivateFile(); + + try { + recNumber = 0; + dataOffset = (short)0; + dataLength = (short)3; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + reportTestOutcome(testCaseNb,bRes); + + /*----------------------------------------- + * Restore the file content + *-----------------------------------------*/ + // Restore EF_LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)4; + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x55); + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0xAA); + recNumber = 2; + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + // Restore EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + recNumber = 0; + dataLength = 3; + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x55); + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/Test_Api_1_Fvw_Updr.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/Test_Api_1_Fvw_Updr.java new file mode 100644 index 0000000000000000000000000000000000000000..5180ffe0f06764d2ccb82c4021fb464aac0b6c2f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/Test_Api_1_Fvw_Updr.java @@ -0,0 +1,96 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Fvw_Updr.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_fvw_updr; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_1_fvw_updr + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_1_Fvw_Updr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_fvw_updr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Fvw_Updr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" // LV Access Domain DAP field + ); + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 23 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "17CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC"); + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..68ccb3effd15dec8a79480eb661bbfbe7fe36dc1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_fvw_updr.Api_1_Fvw_Updr_1 +uicc.test.access.api_1_fvw_updr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/javacard/api_1_fvw_updr.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/javacard/api_1_fvw_updr.cap new file mode 100644 index 0000000000000000000000000000000000000000..3764a0af33ee5410c1d24c6da1c2b3de134457ac Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_fvw_updr/javacard/api_1_fvw_updr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/Api_1_Uex_Coor_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/Api_1_Uex_Coor_1.java new file mode 100644 index 0000000000000000000000000000000000000000..2d4244194885a0ddaeece42cd53022caae344a67 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/Api_1_Uex_Coor_1.java @@ -0,0 +1,60 @@ +//----------------------------------------------------------------------------- +//Api_4_Aex_Coor_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_uex_coor; + +import uicc.test.util.* ; +import uicc.toolkit.*; +import uicc.access.*; + + +public class Api_1_Uex_Coor_1 extends TestToolkitApplet +{ + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_1_Uex_Coor_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Uex_Coor_1 thisApplet = new Api_1_Uex_Coor_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false,(byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + boolean bRes = false; + byte testCaseNb = (byte)0; + + /** Test Case 1 : UICCException with the specified set reason */ + testCaseNb = (byte)1; + bRes = false ; + UICCException UiccEx = new UICCException((short)19); + bRes = (UiccEx.getReason() == (short)19); + + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/Test_Api_1_Uex_Coor.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/Test_Api_1_Uex_Coor.java new file mode 100644 index 0000000000000000000000000000000000000000..1931d080656ef37dbf2acdd35083938534368a67 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/Test_Api_1_Uex_Coor.java @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_uex_coor; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Uex_Coor extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_uex_coor"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Uex_Coor() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9495c23477adcebad00456eef17f70e0109c1484 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_uex_coor.Api_1_Uex_Coor_1 +uicc.test.access.api_1_uex_coor +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/javacard/api_1_uex_coor.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/javacard/api_1_uex_coor.cap new file mode 100644 index 0000000000000000000000000000000000000000..e211b13ffd7b62a6b134582ea3d239ea104cf2fc Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_coor/javacard/api_1_uex_coor.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/Api_1_Uex_Thit_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/Api_1_Uex_Thit_1.java new file mode 100644 index 0000000000000000000000000000000000000000..bbec5b6e5d971cf8b77832414ee400f483958aa8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/Api_1_Uex_Thit_1.java @@ -0,0 +1,150 @@ +//----------------------------------------------------------------------------- +//Api_4_Aex_Thit_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_uex_thit; + +import uicc.test.util.* ; +import uicc.toolkit.*; +import uicc.access.*; +import javacard.framework.* ; + + +public class Api_1_Uex_Thit_1 extends TestToolkitApplet +{ + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_1_Uex_Thit_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_1_Uex_Thit_1 thisApplet = new Api_1_Uex_Thit_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false,(byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Number of tests + byte testCaseNb = (byte)0; + // Result of tests + boolean bRes = false; + + /** Test Case 1 : Throws the JCRE instance of UICCException with the specified reason 0 */ + testCaseNb = (byte)1; + bRes = false ; + try { + UICCException.throwIt((short) 0); + } + catch (UICCException UiccEx) { + bRes= (UiccEx.getReason() == (short)0); + } + catch( Exception e ) { + // Error, throw not as a UICCException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 2 : Throws the JCRE instance of UICCException with the specified reason 1*/ + testCaseNb = (byte)2; + bRes = false ; + + try { + UICCException.throwIt((short) 1); + } + catch (UICCException UiccEx) { + bRes = (UiccEx.getReason() == (short)1 ); + } + catch( Exception e ) { + // Error, throw not as a UICCException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 3 : Throws the JCRE instance of UICCException with the specified reason 0xA55A*/ + testCaseNb = (byte)3; + bRes = false ; + + try { + UICCException.throwIt((short) 0xA55A); + } + catch (UICCException UiccEx) { + bRes = (UiccEx.getReason() == (short)0xA55A ); + } + catch( Exception e ) { + // Error, throw not as a UICCException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 4 : UICCException extends javacard.framework.CardRuntimeException reason 0*/ + testCaseNb = (byte)4; + bRes = false ; + + try { + UICCException.throwIt((short) 0); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)0 ); + } + catch( Exception e ) { + // Error, throw not as a UICCException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 5 : UICCException extends javacard.framework.CardRuntimeException reason 1*/ + testCaseNb = (byte)5; + bRes = false ; + + try { + UICCException.throwIt((short) 1); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)1 ); + } + catch( Exception e ) { + // Error, throw not as a UICCException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 6 : UICCException extends javacard.framework.CardRuntimeException reason 0xA55A*/ + testCaseNb = (byte)6; + bRes = false ; + + try { + UICCException.throwIt((short) 0xA55A); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)0xA55A ); + } + catch( Exception e ) { + // Error, throw not as a UICCException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/Test_Api_1_Uex_Thit.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/Test_Api_1_Uex_Thit.java new file mode 100644 index 0000000000000000000000000000000000000000..07ccc6b79674a8f07fc0ad240c59f8e7195b9492 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/Test_Api_1_Uex_Thit.java @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_uex_thit; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_1_Uex_Thit extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/api_1_uex_thit"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_1_Uex_Thit() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1-6 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "06" + "CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3453f747d83adf8b98dc3d9017a577948e2979f8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_uex_thit.Api_1_Uex_Thit_1 +uicc.test.access.api_1_uex_thit +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/javacard/api_1_uex_thit.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/javacard/api_1_uex_thit.cap new file mode 100644 index 0000000000000000000000000000000000000000..824e036462cde228ef8581661ce69ba62608cfcf Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_uex_thit/javacard/api_1_uex_thit.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/Api_1_Usy_Getf_Bsbb_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/Api_1_Usy_Getf_Bsbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d620d672a6218c4fb994ed23834ec1a32600b26d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/Api_1_Usy_Getf_Bsbb_1.java @@ -0,0 +1,576 @@ +/** + * uicc.access package, getTheFileView tests + * applet 1 + */ + +package uicc.test.access.api_1_usy_getf_bsbb; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_1_Usy_Getf_Bsbb_1 extends TestToolkitApplet implements UICCConstants { + + private boolean bRes; + private static boolean bRes1; + private short counter; + private short event_code; + private byte testCaseNb = 1; + private byte nbProcessCalls = 0; + private byte nbProcessTKCalls = 0; + private short transientAvailable; + private FileView fileView_1 = null; + private FileView fileView_2 = null; + private FileView fileView_3 = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] adf1Aid = new byte[16]; + private static byte[] buffer = new byte[20]; + private byte[] unknownAid = {(byte)'U',(byte)'n',(byte)'k',(byte)'n',(byte)'o',(byte)'w',(byte)'n',(byte)'A',(byte)'I',(byte)'D'}; + private byte[] comp = new byte[10]; + private byte[] checkFCP = new byte[2]; + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private UICCTestConstants uiccTestConstants; + private EditHandler editHandler; + private static final short DATA_SIZE = 10; + private static byte[] data = new byte[DATA_SIZE]; + private static final short TLVHANDLER_MAX_SIZE = 50; + + + /** + * Constructor of the applet + */ + public Api_1_Usy_Getf_Bsbb_1() { + //check this + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, buffer, (short) 0, + (short) 16); + //check this + + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_1_Usy_Getf_Bsbb_1 thisApplet = new Api_1_Usy_Getf_Bsbb_1(); + + + /** Test case 1 + * Method returns null if called before register + */ + + try { + bRes1 = (UICCSystem.getTheFileView(buffer, (short) 0, (byte) 16, JCSystem.CLEAR_ON_RESET) == null); + } + catch(Exception e) { + bRes1 = false; + } + + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + switch (++nbProcessCalls) { + + + /** Testcase 2 + * subpart 5 + */ + case 1: + + + try { + fileView_3 = UICCSystem.getTheFileView(buffer, (short) 0, (byte) 16, JCSystem.CLEAR_ON_DESELECT); + fcpLen = fileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + fileView_3.select(UICCTestConstants.FID_DF_TEST); + fileView_3.select(UICCTestConstants.FID_EF_TARU); + fileView_3.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + /** Testcase 2 + * subpart 6 + */ + case 2: + + try { + fcpLen = fileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_3.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + /** Testcase 6 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_DESELECT FileView object + */ + + case 3: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT); + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_DESELECT); + + try { + UICCSystem.getTheFileView(adf1Aid, (short) 0, (byte) 16, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + + reportTestOutcome(testCaseNb++, bRes); + break; + + default: + super.process(apdu); + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++nbProcessTKCalls) { + + + /** Testcase 1 : Report result + * cf. install(...) + */ + + case 1: + bRes = false; + + try { + bRes = (UICCSystem.getTheFileView(unknownAid,(short) 0, (byte) 10, JCSystem.NOT_A_TRANSIENT_OBJECT) == null); + } + catch(Exception e) { + bRes = false; + } + + bRes &= bRes1; + + reportTestOutcome(testCaseNb++, bRes1); + break; + + + + /** Testcase 2 + * Normal execution + */ + + case 2: + + bRes = true; + + try { + fileView_1 = UICCSystem.getTheFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.NOT_A_TRANSIENT_OBJECT); + fcpLen = fileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + fileView_1.select(UICCTestConstants.FID_DF_TEST); + fileView_1.select(UICCTestConstants.FID_EF_TARU); + fileView_1.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 3: + + try { + fcpLen = fileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + fileView_1.readBinary((short)0, data, (short)0, (short) 3); + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_1.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + + + try { + fileView_2 = UICCSystem.getTheFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.CLEAR_ON_RESET); + fcpLen = fileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_EF_TARU); + fileView_2.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 4: + + try { + fcpLen = fileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_2.readBinary((short)0, data, (short)0, (short) 3); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.NO_EF_SELECTED); + } + + try { + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + case 5: + + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 3 + * FileView context independancy + */ + + case 6: + bRes = true; + + try { + bRes &= (fileView_1 != fileView_2); + bRes &= (fileView_2 != fileView_3); + bRes &= (fileView_3 != fileView_1); + + fileView_1.select(UICCTestConstants.FID_ADF); + fileView_1.select(UICCTestConstants.FID_DF_TEST); + fileView_1.select(UICCTestConstants.FID_EF_LARU); + + fileView_2.select(UICCTestConstants.FID_ADF); + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_EF_CARU); + + fileView_1.readRecord((short) 1, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 4); + comp[0] = (byte) 0x55; + comp[1] = (byte) 0x55; + comp[2] = (byte) 0x55; + comp[3] = (byte) 0x55; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 4) == 0); + + fileView_2.readRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xAA; + comp[1] = (byte) 0xAA; + comp[2] = (byte) 0xAA; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + try { + fileView_3.select(UICCTestConstants.FID_ADF); + fileView_3.select(UICCTestConstants.FID_DF_TEST); + fileView_3.select(UICCTestConstants.FID_EF_CARU); + bRes = false; + + } + catch (SecurityException e) { + bRes &= true; + } + catch (Exception e) { + bRes &= false; + } + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 4 + * ILLEGAL_TRANSIENT SystemException + */ + + case 7: + bRes = false; + + try { + UICCSystem.getTheFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_TRANSIENT); + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 5 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_RESET FileView object + */ + + case 8: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_RESET); + + try { + UICCSystem.getTheFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 7 + * ILLEGAL_VALUE SystemException + */ + + case 9: + bRes = false; + + counter = (short)0; + + for (event_code=(short)3; event_code <= (short)0xFF; event_code++) { + try { + UICCSystem.getTheFileView(adf1Aid,(short) 0, (byte) 16, (byte) event_code); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + } + + if (counter == (short)253) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 8 + * NullPointerException + */ + + case 10: + bRes = false; + + try { + UICCSystem.getTheFileView(null, (short) 0, (byte) 16, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + catch (NullPointerException e) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 9 + * ArrayIndexOutOfBoundsException + */ + + case 11: + bRes = false; + short counter = 0; + + try { + UICCSystem.getTheFileView(adf1Aid, (short) 5, (byte) 16, JCSystem.CLEAR_ON_RESET); + } + catch (ArrayIndexOutOfBoundsException e) { + counter++; + } + + try { + UICCSystem.getTheFileView(adf1Aid, (short) -1, (byte) 16, JCSystem.CLEAR_ON_RESET); + } + catch (ArrayIndexOutOfBoundsException e) { + counter++; + } + + bRes = (counter == (short)2); + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 10 + * SystemException.ILLEGAL_VALUE + */ + + case 12: + bRes = false; + counter = (short)0; + + try { + UICCSystem.getTheFileView(adf1Aid, (short) 0, (byte) 4, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter ++; + } + } + + try { + UICCSystem.getTheFileView(buffer, (short) 0, (byte) 17, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + + bRes = (counter == (short)2); + + reportTestOutcome(testCaseNb++, bRes); + + break; + + + + } + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + + + /** + * Check that the FCP present in the global array fcp[] of + * length fcpLen corresponds to the adf1 AID. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP_adf1() { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + return (editHandler.findAndCompareValue((byte) 0x84, adf1Aid, (short) 0) == 0); + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/Test_Api_1_Usy_Getf_Bsbb.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/Test_Api_1_Usy_Getf_Bsbb.java new file mode 100644 index 0000000000000000000000000000000000000000..0a3cbb38d6a4e502db07d1186d82012967d57711 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/Test_Api_1_Usy_Getf_Bsbb.java @@ -0,0 +1,201 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access package part 1 + * Test source for getTheFileView tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_usy_getf_bsbb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_1_Usy_Getf_Bsbb extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/api_1_usy_getf_bsbb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + static final String AID_ADF_2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_1_Usy_Getf_Bsbb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + /** Test case 1 + * Method returns null if called before register() + */ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 1 + * cf. installation + * subpart 2 + */ + + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Test case 2 + * Normal execution + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + response = test.selectApplication(APPLET_AID_1); + + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 3 + * FileView context independency + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 4 + * ILLEGAL_TRANSIENT SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 5 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_RESET FileView object + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 6 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_DESELECT FileView object + */ + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + + + /** Test case 7 + * ILLEGAL_VALUE SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Test case 8 + * NullPointerException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Testcase 9 + * ArrayIndexOutOfBoundsException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Testcase 10 + * SystemException.ILLEGAL_VALUE + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** + * Check Results and delete packages + */ + + test.reset(); + test.terminalProfileSession("0101"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0ACCCCCC CCCCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..14edf6b570f2e2d35341cdc8d6975b306ae0cbee --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_usy_getf_bsbb.Api_1_Usy_Getf_Bsbb_1 +uicc.test.access.api_1_usy_getf_bsbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/javacard/api_1_usy_getf_bsbb.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/javacard/api_1_usy_getf_bsbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..6c4311bf101e6782a9cadfcaaa369bb0c2565a94 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getf_bsbb/javacard/api_1_usy_getf_bsbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/Api_1_Usy_Getfb_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/Api_1_Usy_Getfb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6dff6109fb1775c7488abb4e60c19b218e1ff0fc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/Api_1_Usy_Getfb_1.java @@ -0,0 +1,443 @@ +/** + * uicc.access package, getTheUICCView tests + * applet 1 + */ + +package uicc.test.access.api_1_usy_getfb; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_1_Usy_Getfb_1 extends TestToolkitApplet implements UICCConstants { + + private boolean bRes; + private static boolean bRes1; + private short counter; + private short event_code; + private byte testCaseNb = 1; + private byte nbProcessCalls = 0; + private byte nbProcessTKCalls = 0; + private short transientAvailable; + private FileView fileView_1 = null; + private FileView fileView_2 = null; + private FileView fileView_3 = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] adf1Aid = new byte[16]; + private byte[] comp = new byte[10]; + private byte[] checkFCP = new byte[2]; + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private UICCTestConstants uiccTestConstants; + private EditHandler editHandler; + private static final short DATA_SIZE = 10; + private static byte[] data = new byte[DATA_SIZE]; + private static final short TLVHANDLER_MAX_SIZE = 50; + + + /** + * Constructor of the applet + */ + public Api_1_Usy_Getfb_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_1_Usy_Getfb_1 thisApplet = new Api_1_Usy_Getfb_1(); + + + /** Test case 1 + * Method returns null if called before register + */ + + try { + bRes1 = (UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET) == null); + } + catch(Exception e) { + bRes1 = false; + } + + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + switch (++nbProcessCalls) { + + + /** Testcase 2 + * subpart 5 + */ + case 1: + + + + try { + fileView_3 = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_DESELECT); + fcpLen = fileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + + fileView_3.select(UICCTestConstants.FID_DF_TEST); + fileView_3.select(UICCTestConstants.FID_EF_TARU); + fileView_3.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + /** Testcase 2 + * subpart 6 + */ + case 2: + + try { + fcpLen = fileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_3.select((short)0x7FFF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + /** Testcase 6 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_DESELECT FileView object + */ + + case 3: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT); + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_DESELECT); + + try { + UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + + reportTestOutcome(testCaseNb++, bRes); + break; + + default: + super.process(apdu); + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++nbProcessTKCalls) { + + + /** Testcase 1 : Report result + * cf. install(...) + */ + + case 1: + reportTestOutcome(testCaseNb++, bRes1); + break; + + + + /** Testcase 2 + * Normal execution + */ + + case 2: + + bRes = true; + + try { + fileView_1 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + fcpLen = fileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + + fileView_1.select(UICCTestConstants.FID_DF_TEST); + fileView_1.select(UICCTestConstants.FID_EF_TARU); + fileView_1.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + case 3: + + try { + fcpLen = fileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_1.select((short)0x7FFF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + + try { + fileView_2 = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + fcpLen = fileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_EF_TARU); + fileView_2.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 4: + + try { + fcpLen = fileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_1.select((short)0x7FFF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + case 5: + + + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 3 + * FileView context independancy + */ + + case 6: + bRes = true; + + try { + bRes &= (fileView_1 != fileView_2); + bRes &= (fileView_2 != fileView_3); + bRes &= (fileView_3 != fileView_1); + + fileView_1.select(UICCTestConstants.FID_MF); + fileView_1.select(UICCTestConstants.FID_DF_TEST); + fileView_1.select(UICCTestConstants.FID_EF_LARU); + + fileView_2.select(UICCTestConstants.FID_MF); + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_EF_CARU); + + fileView_1.readRecord((short) 1, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 4); + comp[0] = (byte) 0x55; + comp[1] = (byte) 0x55; + comp[2] = (byte) 0x55; + comp[3] = (byte) 0x55; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 4) == 0); + + fileView_2.readRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xAA; + comp[1] = (byte) 0xAA; + comp[2] = (byte) 0xAA; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + try { + fileView_3.select(UICCTestConstants.FID_MF); + fileView_3.select(UICCTestConstants.FID_DF_TEST); + fileView_3.select(UICCTestConstants.FID_EF_CARU); + bRes = false; + } + catch (SecurityException e) { + bRes &= true; + } + catch (Exception e) { + bRes &= false; + } + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 4 + * ILLEGAL_TRANSIENT SystemException + */ + + case 7: + bRes = false; + + try { + UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_TRANSIENT); + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 5 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_RESET FileView object + */ + + case 8: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_RESET); + + try { + UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 7 + * ILLEGAL_VALUE SystemException + */ + + case 9: + bRes = false; + + counter = (short)0; + + for (event_code=(short)3; event_code <= (short)0xFF; event_code++) { + try { + UICCSystem.getTheUICCView((byte)event_code); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + } + + if (counter == (short)253) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + } + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/Test_Api_1_Usy_Getfb.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/Test_Api_1_Usy_Getfb.java new file mode 100644 index 0000000000000000000000000000000000000000..2145af48ef1829ea924c09b3b2502d9881172f56 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/Test_Api_1_Usy_Getfb.java @@ -0,0 +1,177 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access package part 1 + * Test source for getTheUICCFileView tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_usy_getfb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_1_Usy_Getfb extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/api_1_usy_getfb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + static final String AID_ADF_2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_1_Usy_Getfb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + /** Test case 1 + * Method returns null if called before register() + */ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 1 + * cf. installation + */ + + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Test case 2 + * Normal execution + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + response = test.selectApplication(APPLET_AID_1); + + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 3 + * FileView context independency + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 4 + * ILLEGAL_TRANSIENT SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 5 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_RESET FileView object + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 6 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_DESELECT FileView object + */ + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + + + /** Test case 7 + * ILLEGAL_VALUE SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** + * Check Results and delete packages + */ + + test.reset(); + test.terminalProfileSession("0101"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..be2b80451327ee075943f9cd894360816a2ab325 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_usy_getfb.Api_1_Usy_Getfb_1 +uicc.test.access.api_1_usy_getfb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/javacard/api_1_usy_getfb.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/javacard/api_1_usy_getfb.cap new file mode 100644 index 0000000000000000000000000000000000000000..cdfbfcf590d4b190e5d469243c5870018e0b2d3a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfb/javacard/api_1_usy_getfb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/Api_1_Usy_Getfob_1.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/Api_1_Usy_Getfob_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d35245861dbc80d9241c3dac2ee54d4c2a866df1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/Api_1_Usy_Getfob_1.java @@ -0,0 +1,517 @@ +/** + * uicc.access package, getTheFileView tests + * applet 1 + */ + +package uicc.test.access.api_1_usy_getfob; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_1_Usy_Getfob_1 extends TestToolkitApplet implements UICCConstants { + + private boolean bRes; + private static boolean bRes1; + private short event_code; + private short counter; + private byte testCaseNb = 1; + private byte nbProcessCalls = 0; + private byte nbProcessTKCalls = 0; + private short transientAvailable; + private FileView fileView_1 = null; + private FileView fileView_2 = null; + private FileView fileView_3 = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] abAdf1Aid = new byte[16]; + private static AID adf1Aid = null; + private byte[] abUnknownAid = {(byte)'U',(byte)'n',(byte)'k',(byte)'n',(byte)'o',(byte)'w',(byte)'n',(byte)'A',(byte)'I',(byte)'D'}; + private AID unknownAid = new AID( abUnknownAid, (short) 0, (byte) 10); + private byte[] comp = new byte[10]; + private byte[] checkFCP = new byte[2]; + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private UICCTestConstants uiccTestConstants; + private EditHandler editHandler; + private static final short DATA_SIZE = 10; + private static byte[] data = new byte[DATA_SIZE]; + private static final short TLVHANDLER_MAX_SIZE = 50; + + + /** + * Constructor of the applet + */ + public Api_1_Usy_Getfob_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, abAdf1Aid, (short) 0, + (short) abAdf1Aid.length); + adf1Aid = new AID(abAdf1Aid, (short) 0, (byte) abAdf1Aid.length); + + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_1_Usy_Getfob_1 thisApplet = new Api_1_Usy_Getfob_1(); + + + /** Test case 1 + * Method returns null if called before register + */ + + try { + bRes1 = (UICCSystem.getTheFileView(adf1Aid, JCSystem.CLEAR_ON_RESET) == null); + } + catch(Exception e) { + bRes1 = false; + } + + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + switch (++nbProcessCalls) { + + + /** Testcase 2 + * subpart 5 + */ + case 1: + + try { + fileView_3 = UICCSystem.getTheFileView(adf1Aid, JCSystem.CLEAR_ON_DESELECT); + fcpLen = fileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + fileView_3.select(UICCTestConstants.FID_DF_TEST); + fileView_3.select(UICCTestConstants.FID_EF_TARU); + fileView_3.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + /** Testcase 2 + * subpart 6 + */ + case 2: + + try { + fcpLen = fileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_3.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + /** Testcase 6 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_DESELECT FileView object + */ + + case 3: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT); + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_DESELECT); + + try { + UICCSystem.getTheFileView(adf1Aid, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + + reportTestOutcome(testCaseNb++, bRes); + break; + + default: + super.process(apdu); + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++nbProcessTKCalls) { + + + /** Testcase 1 : Report result + * cf. install(...) + */ + + case 1: + bRes = false; + + try { + bRes = (UICCSystem.getTheFileView(unknownAid, JCSystem.NOT_A_TRANSIENT_OBJECT) == null); + } + catch(Exception e) { + bRes = false; + } + + bRes &= bRes1; + + reportTestOutcome(testCaseNb++, bRes1); + break; + + + + /** Testcase 2 + * Normal execution + */ + + case 2: + + bRes = true; + + try { + fileView_1 = UICCSystem.getTheFileView(adf1Aid, JCSystem.NOT_A_TRANSIENT_OBJECT); + fcpLen = fileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + fileView_1.select(UICCTestConstants.FID_DF_TEST); + fileView_1.select(UICCTestConstants.FID_EF_TARU); + fileView_1.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 3: + + try { + fcpLen = fileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + fileView_1.readBinary((short)0, data, (short)0, (short) 3); + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_1.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + + + try { + fileView_2 = UICCSystem.getTheFileView(adf1Aid, JCSystem.CLEAR_ON_RESET); + fcpLen = fileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_EF_TARU); + fileView_2.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 4: + + try { + fcpLen = fileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_2.readBinary((short)0, data, (short)0, (short) 3); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.NO_EF_SELECTED); + } + + try { + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + case 5: + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 3 + * FileView context independancy + */ + + case 6: + bRes = true; + + try { + bRes &= (fileView_1 != fileView_2); + bRes &= (fileView_2 != fileView_3); + bRes &= (fileView_3 != fileView_1); + + fileView_1.select(UICCTestConstants.FID_ADF); + fileView_1.select(UICCTestConstants.FID_DF_TEST); + fileView_1.select(UICCTestConstants.FID_EF_LARU); + + fileView_2.select(UICCTestConstants.FID_ADF); + fileView_2.select(UICCTestConstants.FID_DF_TEST); + fileView_2.select(UICCTestConstants.FID_EF_CARU); + + + + + fileView_1.readRecord((short) 1, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 4); + comp[0] = (byte) 0x55; + comp[1] = (byte) 0x55; + comp[2] = (byte) 0x55; + comp[3] = (byte) 0x55; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 4) == 0); + + fileView_2.readRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xAA; + comp[1] = (byte) 0xAA; + comp[2] = (byte) 0xAA; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + try { + fileView_3.select(UICCTestConstants.FID_ADF); + fileView_3.select(UICCTestConstants.FID_DF_TEST); + fileView_3.select(UICCTestConstants.FID_EF_CARU); + bRes = false; + + } + catch (SecurityException e) { + bRes &= true; + } + catch (Exception e) { + bRes &= false; + } + + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 4 + * ILLEGAL_TRANSIENT SystemException + */ + + case 7: + bRes = false; + + try { + UICCSystem.getTheFileView(adf1Aid, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_TRANSIENT); + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 5 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_RESET FileView object + */ + + case 8: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_RESET); + + try { + UICCSystem.getTheFileView(adf1Aid, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 7 + * ILLEGAL_VALUE SystemException + */ + + case 9: + bRes = false; + + counter = (short)0; + + for (event_code=(short)3; event_code <=(short)0xFF; event_code++) { + try { + UICCSystem.getTheFileView(adf1Aid, (byte) event_code); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + } + + if (counter == (short)253) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 8 + * NullPointerException + */ + + case 10: + bRes = false; + + try { + UICCSystem.getTheFileView(null, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + catch (NullPointerException e) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + + adf1Aid = null; + break; + + + } + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + + + /** + * Check that the FCP present in the global array fcp[] of + * length fcpLen corresponds to the adf1 AID. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP_adf1() { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + return (editHandler.findAndCompareValue((byte) 0x84, abAdf1Aid, (short) 0) == 0); + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/Test_Api_1_Usy_Getfob.java b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/Test_Api_1_Usy_Getfob.java new file mode 100644 index 0000000000000000000000000000000000000000..4952d4e4583ec4e5c3a8faa06c0c86b82990def3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/Test_Api_1_Usy_Getfob.java @@ -0,0 +1,185 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access package part 1 + * Test source for getTheFileView tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.api_1_usy_getfob; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_1_Usy_Getfob extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/api_1_usy_getfob"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 10010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 10010102"; + static final String AID_ADF_2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_1_Usy_Getfob() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + /** Test case 1 + * Method returns null if called before register() + */ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 1 + * cf. installation + * subpart 2 + */ + + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Test case 2 + * Normal execution + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + response = test.selectApplication(APPLET_AID_1); + + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 3 + * FileView context independency + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 4 + * ILLEGAL_TRANSIENT SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 5 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_RESET FileView object + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 6 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_DESELECT FileView object + */ + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + + + /** Test case 7 + * ILLEGAL_VALUE SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Test case 8 + * NullPointerException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** + * Check Results and delete packages + */ + + test.reset(); + test.terminalProfileSession("0101"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "08CCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..484968528243fcb7e2cd4c718653fb5bb765d684 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x01:0x00:0x01 uicc.test.access.api_1_usy_getfob.Api_1_Usy_Getfob_1 +uicc.test.access.api_1_usy_getfob +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x10:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/javacard/api_1_usy_getfob.cap b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/javacard/api_1_usy_getfob.cap new file mode 100644 index 0000000000000000000000000000000000000000..38cb7b89425fde2fee292ec1c5b022f3f95c6427 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/api_1_usy_getfob/javacard/api_1_usy_getfob.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/Api_4_Aex_Coor_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/Api_4_Aex_Coor_1.java new file mode 100644 index 0000000000000000000000000000000000000000..83adb1c37cfd000e193747ee5e8103399206ed6f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/Api_4_Aex_Coor_1.java @@ -0,0 +1,60 @@ +//----------------------------------------------------------------------------- +//Api_4_Aex_Coor_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_aex_coor; + +import uicc.test.util.* ; +import uicc.toolkit.*; +import uicc.access.fileadministration.*; + + +public class Api_4_Aex_Coor_1 extends TestToolkitApplet +{ + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_4_Aex_Coor_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Aex_Coor_1 thisApplet = new Api_4_Aex_Coor_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false,(byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + boolean bRes = false; + byte testCaseNb = (byte)0; + + /** Test Case 1 : AdminException with the specified set reason */ + testCaseNb = (byte)1; + bRes = false ; + AdminException UiccEx = new AdminException((short)19); + bRes = (UiccEx.getReason() == (short)19); + + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/Test_Api_4_Aex_Coor.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/Test_Api_4_Aex_Coor.java new file mode 100644 index 0000000000000000000000000000000000000000..02db496f22b3d989f19d94684e8385727a89bc71 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/Test_Api_4_Aex_Coor.java @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_aex_coor; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Aex_Coor extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_aex_coor"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Aex_Coor() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4b0e042a88429a464d21971942895bed559169e4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_aex_coor.Api_4_Aex_Coor_1 +uicc.test.access.fileadministration.api_4_aex_coor +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/javacard/api_4_aex_coor.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/javacard/api_4_aex_coor.cap new file mode 100644 index 0000000000000000000000000000000000000000..f919313342c9c3222752f157ba5b36f9aa658ffe Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_coor/javacard/api_4_aex_coor.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/Api_4_Aex_Thit_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/Api_4_Aex_Thit_1.java new file mode 100644 index 0000000000000000000000000000000000000000..50c31e66b0c864e6fa2dd10a5a20cb34d1f18cd8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/Api_4_Aex_Thit_1.java @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +//Api_4_Aex_Thit_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_aex_thit; + +import uicc.test.util.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import javacard.framework.* ; + + +public class Api_4_Aex_Thit_1 extends TestToolkitApplet +{ + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_4_Aex_Thit_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Aex_Thit_1 thisApplet = new Api_4_Aex_Thit_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false,(byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Number of tests + byte testCaseNb = (byte)0; + // Result of tests + boolean bRes = false; + + /** Test Case 1 : Throws the JCRE instance of AdminException with the specified reason 0 */ + testCaseNb = (byte)1; + bRes = false ; + try { + AdminException.throwIt((short) 0); + } + catch (AdminException AdminEx) { + bRes= (AdminEx.getReason() == (short)0); + } + catch( Exception e ) { + // Error, throw not as an AdminException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 2 : Throws the JCRE instance of AdminException with the specified reason 1*/ + testCaseNb = (byte)2; + bRes = false ; + + try { + AdminException.throwIt((short) 1); + } + catch (AdminException AdminEx) { + bRes = (AdminEx.getReason() == (short)1 ); + } + catch( Exception e ) { + // Error, throw not as an AdminException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 3 : Throws the JCRE instance of AdminException with the specified reason 0xA55A*/ + testCaseNb = (byte)3; + bRes = false ; + + try { + AdminException.throwIt((short) 0xA55A); + } + catch (AdminException AdminEx) { + bRes = (AdminEx.getReason() == (short)0xA55A ); + } + catch( Exception e ) { + // Error, throw not as an AdminException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 4 : AdminException extends javacard.framework.CardRuntimeException reason 0*/ + testCaseNb = (byte)4; + bRes = false ; + + try { + AdminException.throwIt((short) 0); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)0 ); + } + catch( Exception e ) { + // Error, throw not as an AdminException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 5 : AdminException extends javacard.framework.CardRuntimeException reason 1*/ + testCaseNb = (byte)5; + bRes = false ; + + try { + AdminException.throwIt((short) 1); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)1 ); + } + catch( Exception e ) { + // Error, throw not as an AdminException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 6 : AdminException extends javacard.framework.CardRuntimeException reason 0xA55A*/ + testCaseNb = (byte)6; + bRes = false ; + + try { + AdminException.throwIt((short) 0xA55A); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)0xA55A ); + } + catch( Exception e ) { + // Error, throw not as an AdminException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/Test_Api_4_Aex_Thit.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/Test_Api_4_Aex_Thit.java new file mode 100644 index 0000000000000000000000000000000000000000..d371e82f0a82f8bcbd5e3d192fbb0ebdb47475a6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/Test_Api_4_Aex_Thit.java @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_aex_thit; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Aex_Thit extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_aex_thit"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Aex_Thit() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1-6 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "06" + "CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6b5c980e8b92712eb0830371c36cff4bf87ae719 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_aex_thit.Api_4_Aex_Thit_1 +uicc.test.access.fileadministration.api_4_aex_thit +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/javacard/api_4_aex_thit.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/javacard/api_4_aex_thit.cap new file mode 100644 index 0000000000000000000000000000000000000000..1c55a87c04c3c73e4aac8124e578465f268dcec4 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_aex_thit/javacard/api_4_aex_thit.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/Api_4_Afb_Gtaf_Bsbb_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/Api_4_Afb_Gtaf_Bsbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ac83ff9f3b03bb24489e8e5daf82d06c546cca18 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/Api_4_Afb_Gtaf_Bsbb_1.java @@ -0,0 +1,599 @@ +/** + * uicc.access.fileadministration package, getTheAdminFileView tests + * applet 1 + */ + +package uicc.test.access.fileadministration.api_4_afb_gtaf_bsbb; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_4_Afb_Gtaf_Bsbb_1 extends TestToolkitApplet implements UICCConstants { + + private static boolean bRes; + private static boolean bRes1; + private short counter; + private short event_code; + private byte testCaseNb = 1; + private byte nbProcessCalls = 0; + private byte nbProcessTKCalls = 0; + private short transientAvailable; + private AdminFileView adminFileView_1 = null; + private AdminFileView adminFileView_2 = null; + private AdminFileView adminFileView_3 = null; + private byte[] data = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] adf1Aid = new byte[16]; + private static byte[] buffer = new byte[20]; + private byte[] unknownAid = {(byte)'U',(byte)'n',(byte)'k',(byte)'n',(byte)'o',(byte)'w',(byte)'n',(byte)'A',(byte)'I',(byte)'D'}; + private byte[] comp = new byte[10]; + private byte[] checkFCP = new byte[2]; + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private UICCTestConstants uiccTestConstants; + private EditHandler editHandler; + private static final short DATA_SIZE = 10; + private static final short TLVHANDLER_MAX_SIZE = 50; + + + /** + * Constructor of the applet + */ + public Api_4_Afb_Gtaf_Bsbb_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, buffer, (short) 0, + (short) 16); + data = new byte[DATA_SIZE]; + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_4_Afb_Gtaf_Bsbb_1 thisApplet = new Api_4_Afb_Gtaf_Bsbb_1(); + + + /** Test case 1 + * Method returns null if called before register + */ + + try { + bRes1 = (AdminFileViewBuilder.getTheAdminFileView(buffer, (short) 0, (byte) 16, JCSystem.CLEAR_ON_RESET) == null); + } + catch(Exception e) { + bRes1 = false; + } + + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + switch (++nbProcessCalls) { + + + /** Testcase 2 + * subpart 5 + */ + case 1: + + try { + adminFileView_3 = AdminFileViewBuilder.getTheAdminFileView(buffer, (short) 0, (byte) 16, JCSystem.CLEAR_ON_DESELECT); + fcpLen = adminFileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + adminFileView_3.select(UICCTestConstants.FID_DF_TEST); + adminFileView_3.select(UICCTestConstants.FID_EF_TARU); + adminFileView_3.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + break; + + + /** Testcase 2 + * subpart 6 + */ + case 2: + + try { + fcpLen = adminFileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_3.select(UICCTestConstants.FID_ADF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + /** Testcase 6 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_DESELECT FileView object + */ + + case 3: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT); + if (transientAvailable < (short)0x7FFF) + { + // The test could be performed + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_DESELECT); + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) 16, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + } + else + { + // Available memory is greater than 32767, the test could not be performed + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + default: + super.process(apdu); + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++nbProcessTKCalls) { + + + /** Testcase 1 : Report result + * cf. install(...) + */ + + case 1: + bRes = false; + + try { + bRes = (AdminFileViewBuilder.getTheAdminFileView(unknownAid,(short) 0, (byte) 10, JCSystem.NOT_A_TRANSIENT_OBJECT) == null); + } + catch(Exception e) { + bRes = false; + } + + bRes &= bRes1; + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 2 + * Normal execution + */ + + case 2: + + bRes = true; + + try { + adminFileView_1 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.NOT_A_TRANSIENT_OBJECT); + fcpLen = adminFileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + adminFileView_1.select(UICCTestConstants.FID_DF_TEST); + adminFileView_1.select(UICCTestConstants.FID_EF_TARU); + adminFileView_1.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 3: + + try { + fcpLen = adminFileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + adminFileView_1.readBinary((short)0, data, (short)0, (short) 3); + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_1.select(UICCTestConstants.FID_ADF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + + + try { + adminFileView_2 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.CLEAR_ON_RESET); + fcpLen = adminFileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_TARU); + adminFileView_2.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 4: + + try { + fcpLen = adminFileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_2.readBinary((short)0, data, (short)0, (short) 3); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.NO_EF_SELECTED); + } + + try { + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_RFU1); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + case 5: + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 3 + * FileView context independancy + */ + + case 6: + bRes = true; + + try { + bRes &= (adminFileView_1 != adminFileView_2); + bRes &= (adminFileView_2 != adminFileView_3); + bRes &= (adminFileView_3 != adminFileView_1); + + adminFileView_1.select(UICCTestConstants.FID_ADF); + adminFileView_1.select(UICCTestConstants.FID_DF_TEST); + adminFileView_1.select(UICCTestConstants.FID_EF_LARU); + + adminFileView_2.select(UICCTestConstants.FID_ADF); + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_CARU); + + try { + adminFileView_3.select(UICCTestConstants.FID_ADF); + adminFileView_3.select(UICCTestConstants.FID_DF_TEST); + adminFileView_3.select(UICCTestConstants.FID_EF_CARU); + bRes = false; + } + catch (SecurityException e) + { + bRes &=true; + } + catch (Exception e) + { + bRes =false; + } + adminFileView_1.readRecord((short) 1, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 4); + comp[0] = (byte) 0x55; + comp[1] = (byte) 0x55; + comp[2] = (byte) 0x55; + comp[3] = (byte) 0x55; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 4) == 0); + + adminFileView_2.readRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xAA; + comp[1] = (byte) 0xAA; + comp[2] = (byte) 0xAA; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 4 + * ILLEGAL_TRANSIENT SystemException + */ + + case 7: + bRes = false; + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_TRANSIENT); + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 5 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_RESET FileView object + */ + + case 8: + + bRes = false; + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + if (transientAvailable < (short)0x7FFF) + { + // The test could be performed + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_RESET); + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid,(short) 0, (byte) 16, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + } + else + { + // Available memory is greater than 32767, the test could not be performed + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + + break; + + + /** Testcase 7 + * ILLEGAL_VALUE SystemException + */ + + case 9: + bRes = false; + + counter = 0; + + for (event_code=-128; event_code <= 127; event_code++) { + + // Go to next iteration if event_code is a valid value + if ((event_code >= 0) && (event_code <=2)) { + continue; + } + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid,(short) 0, (byte) 16, (byte) event_code); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + } + + if (counter == 253) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 8 + * NullPointerException + */ + + case 10: + bRes = false; + + try { + AdminFileViewBuilder.getTheAdminFileView(null, (short) 0, (byte) 16, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + catch (NullPointerException e) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 9 + * ArrayIndexOutOfBoundsException + */ + + case 11: + bRes = false; + short counter = 0; + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 5, (byte) 16, JCSystem.CLEAR_ON_RESET); + } + catch (ArrayIndexOutOfBoundsException e) { + counter++; + } + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) -1, (byte) 16, JCSystem.CLEAR_ON_RESET); + } + catch (ArrayIndexOutOfBoundsException e) { + counter++; + } + + bRes = (counter == 2); + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 10 + * SystemException.ILLEGAL_VALUE + */ + + case 12: + bRes = false; + counter = 0; + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) 4, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter ++; + } + } + + try { + AdminFileViewBuilder.getTheAdminFileView(buffer, (short) 0, (byte) 17, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + + bRes = (counter == 2); + + reportTestOutcome(testCaseNb++, bRes); + + break; + + + + } + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + + + /** + * Check that the FCP present in the global array fcp[] of + * length fcpLen corresponds to the adf1 AID. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP_adf1() { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + return (editHandler.findAndCompareValue((byte) 0x84, adf1Aid, (short) 0) == 0); + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/Test_Api_4_Afb_Gtaf_Bsbb.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/Test_Api_4_Afb_Gtaf_Bsbb.java new file mode 100644 index 0000000000000000000000000000000000000000..54cb4a95df55a14d8a133d3e24fa5e777c57023c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/Test_Api_4_Afb_Gtaf_Bsbb.java @@ -0,0 +1,201 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access.fileadministration package part 4 + * Test source for getTheAdminFileView tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afb_gtaf_bsbb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_4_Afb_Gtaf_Bsbb extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + static final String AID_ADF_2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_4_Afb_Gtaf_Bsbb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + /** Test case 1 + * Method returns null if called before register() + */ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 1 + * cf. installation + * subpart 2 + */ + + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Test case 2 + * Normal execution + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + response = test.selectApplication(APPLET_AID_1); + + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 3 + * FileView context independency + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 4 + * ILLEGAL_TRANSIENT SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 5 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_RESET FileView object + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 6 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_DESELECT FileView object + */ + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 7 + * ILLEGAL_VALUE SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Test case 8 + * NullPointerException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Testcase 9 + * ArrayIndexOutOfBoundsException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Testcase 10 + * SystemException.ILLEGAL_VALUE + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** + * Check Results and delete packages + */ + + test.reset(); + test.terminalProfileSession("0101"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0ACCCCCC CCCCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..76169b062ddd040c6b12bc99e69f9872550e5e23 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afb_gtaf_bsbb.Api_4_Afb_Gtaf_Bsbb_1 +uicc.test.access.fileadministration.api_4_afb_gtaf_bsbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/javacard/api_4_afb_gtaf_bsbb.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/javacard/api_4_afb_gtaf_bsbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..a79b11c2a2f452d9d90e6b7ccbad4448eef00c60 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtaf_bsbb/javacard/api_4_afb_gtaf_bsbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/Api_4_Afb_Gtafb_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/Api_4_Afb_Gtafb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6258a9133231214134b645af3167b8dff7e80862 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/Api_4_Afb_Gtafb_1.java @@ -0,0 +1,468 @@ +/** + * uicc.access.fileadministration package, getTheUICCAdminFileView tests + * applet 1 + */ + +package uicc.test.access.fileadministration.api_4_afb_gtafb; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_4_Afb_Gtafb_1 extends TestToolkitApplet implements UICCConstants { + + private boolean bRes; + private static boolean bRes1; + private short counter; + private short event_code; + private byte testCaseNb = 1; + private byte nbProcessCalls = 0; + private byte nbProcessTKCalls = 0; + private short transientAvailable; + private AdminFileView adminFileView_1 = null; + private AdminFileView adminFileView_2 = null; + private AdminFileView adminFileView_3 = null; + private byte[] data = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] adf1Aid = new byte[16]; + private byte[] comp = new byte[10]; + private byte[] checkFCP = new byte[2]; + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private UICCTestConstants uiccTestConstants; + private EditHandler editHandler; + private static final short DATA_SIZE = 10; + private static final short TLVHANDLER_MAX_SIZE = 50; + + + /** + * Constructor of the applet + */ + public Api_4_Afb_Gtafb_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + data = new byte[DATA_SIZE]; + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_4_Afb_Gtafb_1 thisApplet = new Api_4_Afb_Gtafb_1(); + + + /** Test case 1 + * Method returns null if called before register + */ + + try { + bRes1 = (AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET) == null); + } + catch(Exception e) { + bRes1 = false; + } + + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + switch (++nbProcessCalls) { + + + /** Testcase 2 + * subpart 5 + */ + case 1: + + try { + adminFileView_3 = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_DESELECT); + fcpLen = adminFileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + + adminFileView_3.select(UICCTestConstants.FID_DF_TEST); + adminFileView_3.select(UICCTestConstants.FID_EF_TARU); + adminFileView_3.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + /** Testcase 2 + * subpart 6 + */ + case 2: + + try { + fcpLen = adminFileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_3.select((short)0x7FFF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + /** Testcase 6 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_DESELECT FileView object + */ + + case 3: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT); + if (transientAvailable < (short)0x7FFF) + { + // The test could be performed + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_DESELECT); + try { + AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + } + else + { + // Available memory is greater than 32767, the test could not be performed + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + default: + super.process(apdu); + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++nbProcessTKCalls) { + + + /** Testcase 1 : Report result + * cf. install(...) + */ + + case 1: + reportTestOutcome(testCaseNb++, bRes1); + break; + + + + /** Testcase 2 + * Normal execution + */ + + case 2: + + bRes = true; + + try { + adminFileView_1 = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.NOT_A_TRANSIENT_OBJECT); + fcpLen = adminFileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + + adminFileView_1.select(UICCTestConstants.FID_DF_TEST); + adminFileView_1.select(UICCTestConstants.FID_EF_TARU); + adminFileView_1.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + case 3: + + try { + fcpLen = adminFileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_1.select((short)0x7FFF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + + try { + adminFileView_2 = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + fcpLen = adminFileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_TARU); + adminFileView_2.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 4: + + try { + fcpLen = adminFileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_MF); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_1.select((short)0x7FFF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + case 5: + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 3 + * FileView context independancy + */ + + case 6: + bRes = true; + + try { + bRes &= (adminFileView_1 != adminFileView_2); + bRes &= (adminFileView_2 != adminFileView_3); + bRes &= (adminFileView_3 != adminFileView_1); + + adminFileView_1.select(UICCTestConstants.FID_MF); + adminFileView_1.select(UICCTestConstants.FID_DF_TEST); + adminFileView_1.select(UICCTestConstants.FID_EF_LARU); + + adminFileView_2.select(UICCTestConstants.FID_MF); + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_CARU); + + try + { + adminFileView_3.select(UICCTestConstants.FID_MF); + adminFileView_3.select(UICCTestConstants.FID_DF_TEST); + adminFileView_3.select(UICCTestConstants.FID_EF_CARU); + bRes = false; + } + catch (SecurityException e) + { + bRes &=true; + } + catch (Exception e) + { + bRes = false; + } + + adminFileView_1.readRecord((short) 1, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 4); + comp[0] = (byte) 0x55; + comp[1] = (byte) 0x55; + comp[2] = (byte) 0x55; + comp[3] = (byte) 0x55; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 4) == 0); + + adminFileView_2.readRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xAA; + comp[1] = (byte) 0xAA; + comp[2] = (byte) 0xAA; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 4 + * ILLEGAL_TRANSIENT SystemException + */ + + case 7: + bRes = false; + + try { + AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_TRANSIENT); + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 5 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_RESET FileView object + */ + + case 8: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + if (transientAvailable < (short)0x7FFF) + { + // The test could be performed + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_RESET); + try { + AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + } + else + { + // Available memory is greater than 32767, the test could not be performed + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 7 + * ILLEGAL_VALUE SystemException + */ + + case 9: + bRes = false; + + counter = 0; + + for (event_code=-128; event_code <= 127; event_code++) { + + // Go to next iteration if event_code is a valid value + if ((event_code >= 0) && (event_code <=2)) { + continue; + } + + try { + AdminFileViewBuilder.getTheUICCAdminFileView((byte)event_code); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + } + + if (counter == 253) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + + break; + + } + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/Test_Api_4_Afb_Gtafb.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/Test_Api_4_Afb_Gtafb.java new file mode 100644 index 0000000000000000000000000000000000000000..2a986ffd36489012521290b0e769efdfa62e7b56 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/Test_Api_4_Afb_Gtafb.java @@ -0,0 +1,176 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access.fileadministration package part 4 + * Test source for getTheUICCAdminFileView tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afb_gtafb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_4_Afb_Gtafb extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afb_gtafb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + static final String AID_ADF_2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_4_Afb_Gtafb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + /** Test case 1 + * Method returns null if called before register() + */ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 1 + * cf. installation + */ + + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Test case 2 + * Normal execution + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + response = test.selectApplication(APPLET_AID_1); + + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 3 + * FileView context independency + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 4 + * ILLEGAL_TRANSIENT SystemException + */ + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 5 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_RESET FileView object + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 6 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_DESELECT FileView object + */ + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 7 + * ILLEGAL_VALUE SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** + * Check Results and delete packages + */ + + test.reset(); + test.terminalProfileSession("0101"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..81a0d056cc96ad4abb755ff80c81ff5d94666746 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afb_gtafb.Api_4_Afb_Gtafb_1 +uicc.test.access.fileadministration.api_4_afb_gtafb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/javacard/api_4_afb_gtafb.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/javacard/api_4_afb_gtafb.cap new file mode 100644 index 0000000000000000000000000000000000000000..7bdb8cea0ecd89b1210f89cf0c7efb71336193e3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafb/javacard/api_4_afb_gtafb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/Api_4_Afb_Gtafob_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/Api_4_Afb_Gtafob_1.java new file mode 100644 index 0000000000000000000000000000000000000000..62e6544ff969c7285bd52c8dff35f09d1c253a45 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/Api_4_Afb_Gtafob_1.java @@ -0,0 +1,540 @@ +/** + * uicc.access.fileadministration package, getTheAdminFileView tests + * applet 1 + */ + +package uicc.test.access.fileadministration.api_4_afb_gtafob; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_4_Afb_Gtafob_1 extends TestToolkitApplet implements UICCConstants { + + private boolean bRes; + private static boolean bRes1; + private short event_code; + private short counter; + private byte testCaseNb = 1; + private byte nbProcessCalls = 0; + private byte nbProcessTKCalls = 0; + private short transientAvailable; + private AdminFileView adminFileView_1 = null; + private AdminFileView adminFileView_2 = null; + private AdminFileView adminFileView_3 = null; + private byte[] data = null; + private short fcpLen; + private byte[] fcp = new byte[TLVHANDLER_MAX_SIZE]; + private byte[] abAdf1Aid = new byte[16]; + private static AID adf1AidTmp = null; + private AID adf1Aid = null; + private byte[] abUnknownAid = {(byte)'U',(byte)'n',(byte)'k',(byte)'n',(byte)'o',(byte)'w',(byte)'n',(byte)'A',(byte)'I',(byte)'D'}; + private AID unknownAid = new AID( abUnknownAid, (short) 0, (byte) 10); + private byte[] comp = new byte[10]; + private byte[] checkFCP = new byte[2]; + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private UICCTestConstants uiccTestConstants; + private EditHandler editHandler; + private static final short DATA_SIZE = 10; + private static final short TLVHANDLER_MAX_SIZE = 50; + + + /** + * Constructor of the applet + */ + public Api_4_Afb_Gtafob_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_MAX_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, abAdf1Aid, (short) 0, + (short) abAdf1Aid.length); + adf1AidTmp = new AID(abAdf1Aid, (short) 0, (byte) abAdf1Aid.length); + adf1Aid = adf1AidTmp; + data = new byte[DATA_SIZE]; + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_4_Afb_Gtafob_1 thisApplet = new Api_4_Afb_Gtafob_1(); + + + /** Test case 1 + * Method returns null if called before register + */ + + try { + bRes1 = (AdminFileViewBuilder.getTheAdminFileView(adf1AidTmp, JCSystem.CLEAR_ON_RESET) == null); + adf1AidTmp = null; + } + catch(Exception e) { + bRes1 = false; + } + + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + if (selectingApplet()) { + switch (++nbProcessCalls) { + + + /** Testcase 2 + * subpart 5 + */ + case 1: + + try { + adminFileView_3 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, JCSystem.CLEAR_ON_DESELECT); + fcpLen = adminFileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + adminFileView_3.select(UICCTestConstants.FID_DF_TEST); + adminFileView_3.select(UICCTestConstants.FID_EF_TARU); + adminFileView_3.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + /** Testcase 2 + * subpart 6 + */ + case 2: + + try { + fcpLen = adminFileView_3.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_3.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + /** Testcase 6 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_DESELECT FileView object + */ + + case 3: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT); + if (transientAvailable < (short)0x7FFF) + { + // The test could be performed + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_DESELECT); + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + } + else + { + // Available memory is greater than 32767, the test could not be performed + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + default: + super.process(apdu); + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++nbProcessTKCalls) { + + + /** Testcase 1 : Report result + * cf. install(...) + */ + + case 1: + bRes = false; + + try { + bRes = (AdminFileViewBuilder.getTheAdminFileView(unknownAid, JCSystem.NOT_A_TRANSIENT_OBJECT) == null); + } + catch(Exception e) { + bRes = false; + } + + bRes &= bRes1; + + reportTestOutcome(testCaseNb++, bRes1); + break; + + + + /** Testcase 2 + * Normal execution + */ + + case 2: + + bRes = true; + + try { + adminFileView_1 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, JCSystem.NOT_A_TRANSIENT_OBJECT); + fcpLen = adminFileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + adminFileView_1.select(UICCTestConstants.FID_DF_TEST); + adminFileView_1.select(UICCTestConstants.FID_EF_TARU); + adminFileView_1.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 3: + + try { + fcpLen = adminFileView_1.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP(UICCTestConstants.FID_DF_TEST); + adminFileView_1.readBinary((short)0, data, (short)0, (short) 3); + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_1.select(UICCTestConstants.FID_MF); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + + + try { + adminFileView_2 = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, JCSystem.CLEAR_ON_RESET); + fcpLen = adminFileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_TARU); + adminFileView_2.readBinary((short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xFF; + comp[1] = (byte) 0xFF; + comp[2] = (byte) 0xFF; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + break; + + + case 4: + + try { + fcpLen = adminFileView_2.status(fcp, (short) 0, (short) fcp.length); + bRes &= checkFCP_adf1(); + } + catch (Exception e) { + bRes = false; + } + + try { + adminFileView_2.readBinary((short)0, data, (short)0, (short) 3); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.NO_EF_SELECTED); + } + + try { + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_RFU1); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + break; + + + case 5: + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 3 + * FileView context independancy + */ + + case 6: + bRes = true; + + try { + bRes &= (adminFileView_1 != adminFileView_2); + bRes &= (adminFileView_2 != adminFileView_3); + bRes &= (adminFileView_3 != adminFileView_1); + + adminFileView_1.select(UICCTestConstants.FID_ADF); + adminFileView_1.select(UICCTestConstants.FID_DF_TEST); + adminFileView_1.select(UICCTestConstants.FID_EF_LARU); + + adminFileView_2.select(UICCTestConstants.FID_ADF); + adminFileView_2.select(UICCTestConstants.FID_DF_TEST); + adminFileView_2.select(UICCTestConstants.FID_EF_CARU); + + try + { + adminFileView_3.select(UICCTestConstants.FID_ADF); + adminFileView_3.select(UICCTestConstants.FID_DF_TEST); + adminFileView_3.select(UICCTestConstants.FID_EF_CARU); + bRes = false; + } + catch (SecurityException e) + { + bRes &=true; + } + catch (Exception e) + { + bRes = false; + } + + adminFileView_1.readRecord((short) 1, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 4); + comp[0] = (byte) 0x55; + comp[1] = (byte) 0x55; + comp[2] = (byte) 0x55; + comp[3] = (byte) 0x55; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 4) == 0); + + adminFileView_2.readRecord((short) 2, REC_ACC_MODE_ABSOLUTE, (short)0, data, (short)0, (short) 3); + comp[0] = (byte) 0xAA; + comp[1] = (byte) 0xAA; + comp[2] = (byte) 0xAA; + bRes &= (Util.arrayCompare(comp, (short) 0, data, (short) 0, (short) 3) == 0); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + + /** Testcase 4 + * ILLEGAL_TRANSIENT SystemException + */ + + case 7: + bRes = false; + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, JCSystem.CLEAR_ON_DESELECT); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_TRANSIENT); + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 5 + * NO_TRANSIENT_SPACE SystemException with CLEAR_ON_RESET FileView object + */ + + case 8: + bRes = false; + + transientAvailable = JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + if (transientAvailable < (short)0x7FFF) + { + // The test could be performed + data = JCSystem.makeTransientByteArray( transientAvailable, JCSystem.CLEAR_ON_RESET); + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, JCSystem.CLEAR_ON_RESET); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.NO_TRANSIENT_SPACE); + } + + data = null; + JCSystem.requestObjectDeletion(); + } + else + { + // Available memory is greater than 32767, the test could not be performed + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 7 + * ILLEGAL_VALUE SystemException + */ + + case 9: + bRes = false; + + counter = 0; + + for (event_code=-128; event_code <= 127; event_code++) { + + // Go to next iteration if event_code is a valid value + if ((event_code >= 0) && (event_code <=2)) { + continue; + } + + try { + AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (byte) event_code); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + counter++; + } + } + } + + if (counter == 253) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + break; + + + /** Testcase 8 + * NullPointerException + */ + + case 10: + bRes = false; + + try { + AdminFileViewBuilder.getTheAdminFileView(null, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + catch (NullPointerException e) { + bRes = true; + } + + reportTestOutcome(testCaseNb++, bRes); + + break; + + + } + } + + + /** + * Check that the current DF present in the global array fcp[] of + * length fcpLen corresponds to the fid given as parameter. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP(short fid) { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + checkFCP[0] = (byte) ((fid >> 8) & 0x00FF); + checkFCP[1] = (byte) (fid & 0x00FF); + return (editHandler.findAndCompareValue((byte) 0x83, checkFCP, (short) 0) == 0); + } + + + /** + * Check that the FCP present in the global array fcp[] of + * length fcpLen corresponds to the adf1 AID. + * + * @param fid + * @return true if the fid corresponds to the DF present in fcp[] + */ + + private boolean checkFCP_adf1() { + + //fcp contains BERTL and length can be 1 or 2 bytes + byte offsetFcpTLVList=2; + + editHandler.clear(); + if (fcp[1]==0x81){ + offsetFcpTLVList=3; + } + editHandler.appendArray(fcp, (short) offsetFcpTLVList, (short) (fcpLen-offsetFcpTLVList)); + return (editHandler.findAndCompareValue((byte) 0x84, abAdf1Aid, (short) 0) == 0); + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/Test_Api_4_Afb_Gtafob.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/Test_Api_4_Afb_Gtafob.java new file mode 100644 index 0000000000000000000000000000000000000000..7ebc038f48bd9f6428cdb72e3b4bf685448caf30 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/Test_Api_4_Afb_Gtafob.java @@ -0,0 +1,185 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access.fileadministration package part 4 + * Test source for getTheAdminFileView tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afb_gtafob; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_4_Afb_Gtafob extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afb_gtafob"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + static final String AID_ADF_2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_4_Afb_Gtafob() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + /** Test case 1 + * Method returns null if called before register() + */ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 1 + * cf. installation + * subpart 2 + */ + + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Test case 2 + * Normal execution + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + response = test.selectApplication(APPLET_AID_1); + + + test.reset(); + test.terminalProfileSession("0101"); + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 3 + * FileView context independency + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 4 + * ILLEGAL_TRANSIENT SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 5 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_RESET FileView object + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** Test case 6 + * NO_TRANSIENT_SPACE Exception with CLEAR_ON_DESELECT FileView object + */ + + response = test.selectApplication(APPLET_AID_1); + response = test.selectApplication(AID_ADF_2); + + test.reset(); + test.terminalProfileSession("0101"); + + + /** Test case 7 + * ILLEGAL_VALUE SystemException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Test case 8 + * NullPointerException + */ + + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /** + * Check Results and delete packages + */ + + test.reset(); + test.terminalProfileSession("0101"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "08CCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..63e441eb59f9afa8d94a8798788e81125a2222e9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afb_gtafob.Api_4_Afb_Gtafob_1 +uicc.test.access.fileadministration.api_4_afb_gtafob +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/javacard/api_4_afb_gtafob.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/javacard/api_4_afb_gtafob.cap new file mode 100644 index 0000000000000000000000000000000000000000..84b31489be04213142e41ccff28645d1d3d3b23a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afb_gtafob/javacard/api_4_afb_gtafob.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/Api_4_Afv_Actf_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/Api_4_Afv_Actf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..4f4b3f3384030c4c4644a85f58c12eaae9391161 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/Api_4_Afv_Actf_1.java @@ -0,0 +1,175 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Actf_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_actf; + +import uicc.test.util.* ; +import javacard.framework.*; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; + + +public class Api_4_Afv_Actf_1 extends TestToolkitApplet +{ + private AdminFileView UiccFileView = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Actf_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Actf_1 thisApplet = new Api_4_Afv_Actf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + UiccFileView.activateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : Activate a deactivated file + // ----------------------------------------------------------------- + testCaseNb = 2; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_MF); + UiccFileView.select((short)UICCTestConstants.FID_EF_UICC); + // Points 2 and 3 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + UiccFileView.deactivateFile(); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + // Point 4 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.REF_DATA_INVALIDATED) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + // Point 5 and 6 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.activateFile(); + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + bRes &= true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Activate an activated file + // ----------------------------------------------------------------- + testCaseNb = 3; + bRes = false; + try + { + UiccFileView.activateFile(); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : Access condition not fulfilled + // ----------------------------------------------------------------- + testCaseNb = 4; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + UiccFileView.select((short)UICCTestConstants.FID_EF_LADA); + try + { + UiccFileView.activateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/Test_Api_4_Afv_Actf.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/Test_Api_4_Afv_Actf.java new file mode 100644 index 0000000000000000000000000000000000000000..3ecf95e5e94893558d44d6e7783f7563c1839713 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/Test_Api_4_Afv_Actf.java @@ -0,0 +1,91 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_actf; + +//---------------------------------------1-------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Actf extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_actf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Actf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402FFFDFF" + // LV Access Domain for UICC file system = All except ADM2 + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402FFFDFF" + // LV Access Domain for ADF1 file system = All except ADM22 + "00" ); //+ // LV Access Domain DAP field + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04" + "CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..75a624afcf9e20cb5e0ecd09397c4177eae38ea3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_actf.Api_4_Afv_Actf_1 +uicc.test.access.fileadministration.api_4_afv_actf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/javacard/api_4_afv_actf.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/javacard/api_4_afv_actf.cap new file mode 100644 index 0000000000000000000000000000000000000000..89b5c9908e86656c8f71ed59c6a40c399e9354a1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_actf/javacard/api_4_afv_actf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/Api_4_Afv_Crtf_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/Api_4_Afv_Crtf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e0679619fc933f2d82d8a672dafafb5cd2889b6c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/Api_4_Afv_Crtf_1.java @@ -0,0 +1,359 @@ +/** + * uicc.access.fileadministration package, createFile tests + * applet 1 + */ + +package uicc.test.access.fileadministration.api_4_afv_crtf; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_4_Afv_Crtf_1 extends TestToolkitApplet implements UICCConstants { + private boolean bRes; + private byte testCaseNb = 1; + + private AdminFileView uiccAdminFileView = null; + private AdminFileView adf1AdminFileView = null; + + private static EditHandler editHandler; + private final short TLVHANDLER_SIZE = 50; + private static byte[] data = new byte[10]; + private byte[] adf1Aid = new byte[16]; + private UICCTestConstants uiccTestConstants; + + + private byte[] incorrectParameters = new byte[] { + (byte) 0x42, (byte) 0x42, (byte) 0x42, (byte) 0x42 + }; + + + private byte[] createFile_EF_RFU0 = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x29, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x10, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFile_EF_RFU0_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x29, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x10, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFile_EF_RFU1 = new byte[] { + (byte) 0x82, (byte) 0x04, (byte) 0x42, (byte) 0x21, (byte) 0x00, (byte) 0x01, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2A, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x01, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + + private byte[] createFile_EF_RFU2 = new byte[] { + (byte) 0x82, (byte) 0x04, (byte) 0x46, (byte) 0x21, (byte) 0x00, (byte) 0x03, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2B, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x03, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + + private byte[] createFile_EF_TARU = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x03, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x20, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFile_DF_RFU1_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x5F, (byte) 0x01, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x30, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01,(byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFile_DF_TEST = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x4A, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x30, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01,(byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + + + /** + * Constructor of the applet + */ + public Api_4_Afv_Crtf_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_4_Afv_Crtf_1 thisApplet = new Api_4_Afv_Crtf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (testCaseNb) { + + /** Testcase 1 + * Create an EF + */ + case 1: + bRes = true; + + try { + uiccAdminFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU0, (short) 0,(short) createFile_EF_RFU0.length); + uiccAdminFileView.createFile(editHandler); + + data[0] = (byte) 0x12; + data[1] = (byte) 0x34; + data[2] = (byte) 0x56; + uiccAdminFileView.select(UICCTestConstants.FID_EF_RFU0); + uiccAdminFileView.updateBinary((short) 0, data, (short)0, (short)3); + + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU1, (short) 0,(short) createFile_EF_RFU1.length); + uiccAdminFileView.createFile(editHandler); + + data[3] = (byte) 0x02; + uiccAdminFileView.select(UICCTestConstants.FID_EF_RFU1); + uiccAdminFileView.updateRecord((short)1, UICCConstants.REC_ACC_MODE_ABSOLUTE,(short)0, data, (short)3, (short)1); + + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU2, (short) 0,(short) createFile_EF_RFU2.length); + uiccAdminFileView.createFile(editHandler); + + uiccAdminFileView.select(UICCTestConstants.FID_EF_RFU2); + uiccAdminFileView.updateRecord((short)0, UICCConstants.REC_ACC_MODE_PREVIOUS,(short)0, data, (short)0, (short)3); + + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + /** test case 2 + * create a DF in ADF1 + */ + case 2: + bRes = true; + + try { + adf1AdminFileView = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(createFile_DF_RFU1_inADF, (short) 0,(short) createFile_DF_RFU1_inADF.length); + adf1AdminFileView.createFile(editHandler); + + adf1AdminFileView.select(UICCTestConstants.FID_DF_RFU1); + + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU0_inADF, (short) 0,(short) createFile_EF_RFU0_inADF.length); + adf1AdminFileView.createFile(editHandler); + + adf1AdminFileView.select(UICCTestConstants.FID_EF_RFU0); + adf1AdminFileView.updateBinary((short) 0, data, (short)0, (short)3); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + /** test case 3 + * Call createFile with a null viewHandler + */ + case 3: + bRes = false; + try { + uiccAdminFileView.createFile(null); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + /** test case 4 + * Call createFile with incorrect parameters + */ + + case 4: + bRes = false; + try { + editHandler.clear(); + editHandler.appendArray(incorrectParameters, (short) 0,(short) incorrectParameters.length); + uiccAdminFileView.createFile(editHandler); + } + catch (AdminException e) { + bRes = (e.getReason() == AdminException.INCORRECT_PARAMETERS); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + /** test case 5 + * EF already exists + */ + + case 5: + bRes = false; + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(createFile_EF_TARU, (short) 0,(short) createFile_EF_TARU.length); + uiccAdminFileView.createFile(editHandler); + } + catch (AdminException e) { + bRes = (e.getReason() == AdminException.FILE_ALREADY_EXISTS); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + /** test case 6 + * EF already exists (DF) + */ + + case 6: + bRes = false; + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + + editHandler.clear(); + editHandler.appendArray(createFile_DF_TEST, (short) 0,(short) createFile_DF_TEST.length); + uiccAdminFileView.createFile(editHandler); + } + catch (AdminException e) { + bRes = (e.getReason() == AdminException.FILE_ALREADY_EXISTS); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + break; + + + /** test case 7 + * Security status not satisfied + */ + + case 7: + bRes = false; + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_DF_ARR2); + + editHandler.clear(); + editHandler.appendArray(createFile_EF_TARU, (short) 0,(short) createFile_EF_TARU.length); + uiccAdminFileView.createFile(editHandler); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + // Nullify variables to allow deletion + data = null; + editHandler = null; + uiccTestConstants = null; + + break; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/Test_Api_4_Afv_Crtf.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/Test_Api_4_Afv_Crtf.java new file mode 100644 index 0000000000000000000000000000000000000000..0f283f060273a6224d8d9b3033f05e98b6b57ff7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/Test_Api_4_Afv_Crtf.java @@ -0,0 +1,179 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access.fileadministration package part 4 + * Test source for createFile tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_crtf; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_4_Afv_Crtf extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_crtf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + static final String DF_TELECOM = "7F10"; + static final String MF = "3F00"; + static final String DF_TEST = "7F4A"; + static final String EF_TNR = "6F01"; + static final String EF_TNU = "6F02"; + static final String EF_TARU = "6F03"; + static final String EF_CNR = "6F04"; + static final String EF_CARU = "6F09"; + static final String EF_LNU = "6F0B"; + static final String EF_LARU = "6F0C"; + static final String EF_TDAC = "6F0F"; + static final String EF_LUPC = "6F18"; + static final String EF_NOSH = "6F1B"; + static final String EF_RFU0 = "6F29"; + static final String EF_RFU1 = "6F2A"; + static final String EF_RFU2 = "6F2B"; + static final String DF_RFU1 = "5F01"; + static final String DF_RFU2 = "5F02"; + static final String DF_RFU3 = "5F03"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_4_Afv_Crtf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** test case 1 + * Create an EF + */ + + test.unrecognizedEnvelope(); + + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_RFU0); + response = test.readBinary("0000", "03"); + result &= response.checkData("123456"); + + test.selectFile(EF_RFU1); + response = test.readRecord("01", "04", "01"); + result &= response.checkData("02"); + + test.selectFile(EF_RFU2); + response = test.readRecord("01", "04", "03"); + result &= response.checkData("123456"); + + + /** test case 2 + * Create a DF in ADF1 + */ + + test.unrecognizedEnvelope(); + + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(DF_RFU1); + test.selectFile(EF_RFU0); + response = test.readBinary("0000", "03"); + result &= response.checkData("123456"); + + + /** test cases 3, 4, 5, 6, 7 + * 3. Call createFile with a null viewHandler + * 4. Call createFile with incorrect parameters + * 5. EF already exists + * 6. EF already exists (DF) + * 7. Security status not satisfied + */ + + test.reset(); + test.terminalProfileSession("0101"); + + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + + + + /** + * Clean Up + */ + + test.selectFile(MF); + test.selectFile(DF_TEST); + test.deleteFile(EF_RFU0); + test.deleteFile(EF_RFU1); + test.deleteFile(EF_RFU2); + + test.selectApplication(AID_ADF_1); + test.selectFile(DF_TEST); + test.selectFile(DF_RFU1); + test.deleteFile(EF_RFU0); + test.selectFile(DF_TEST); + test.deleteFile(DF_RFU1); + + + /** + * Check Results and delete packages + */ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..249ddb22c38ef3723ba924d5ae3f98019f11d640 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_crtf.Api_4_Afv_Crtf_1 +uicc.test.access.fileadministration.api_4_afv_crtf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/javacard/api_4_afv_crtf.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/javacard/api_4_afv_crtf.cap new file mode 100644 index 0000000000000000000000000000000000000000..8c06d07d8822d5ccc3299628959b5077b0c1bea0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_crtf/javacard/api_4_afv_crtf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/Api_4_Afv_Dacf_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/Api_4_Afv_Dacf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b0eb60c8960b1f36b6980b7cc6178e7a68d4fbfc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/Api_4_Afv_Dacf_1.java @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Dacf_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_dacf; + +import uicc.test.util.* ; +import javacard.framework.*; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; + + +public class Api_4_Afv_Dacf_1 extends TestToolkitApplet +{ + private AdminFileView UiccFileView = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Dacf_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Dacf_1 thisApplet = new Api_4_Afv_Dacf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + UiccFileView.deactivateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : Deactivate an activated file + // ----------------------------------------------------------------- + testCaseNb = 2; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_MF); + UiccFileView.select((short)UICCTestConstants.FID_EF_UICC); + // Points 2, 3 and 4 + try + { + byte rdBuff[] = new byte [1]; + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + UiccFileView.deactivateFile(); + UiccFileView.readBinary((short)0, rdBuff, (short)0, (short)1); + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.REF_DATA_INVALIDATED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Deactivate a deactivated file + // ----------------------------------------------------------------- + testCaseNb = 3; + bRes = false; + try + { + UiccFileView.deactivateFile(); + bRes = true; + // Restore EFuicc in its initial state + UiccFileView.activateFile(); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : Access condition not fulfilled + // ----------------------------------------------------------------- + testCaseNb = 4; + bRes = false; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + UiccFileView.select((short)UICCTestConstants.FID_EF_LADA); + try + { + UiccFileView.deactivateFile(); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/Test_Api_4_Afv_Dacf.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/Test_Api_4_Afv_Dacf.java new file mode 100644 index 0000000000000000000000000000000000000000..4c8d3f36d79c778f86e4c86c4e44b8f7c02f38f3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/Test_Api_4_Afv_Dacf.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_dacf; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Dacf extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_dacf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Dacf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402FFFDFF" + // LV Access Domain for UICC file system = All except ADM2 + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402FFFDFF" + // LV Access Domain for ADF1 file system = All except ADM2 + "00" ); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04" + "CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..aa9969458dbb432b4358156b06cb824789d093eb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_dacf.Api_4_Afv_Dacf_1 +uicc.test.access.fileadministration.api_4_afv_dacf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/javacard/api_4_afv_dacf.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/javacard/api_4_afv_dacf.cap new file mode 100644 index 0000000000000000000000000000000000000000..0d0a17f24ef25a1d19b85eb330ab876e9471213b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dacf/javacard/api_4_afv_dacf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/Api_4_Afv_Dltf_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/Api_4_Afv_Dltf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..59e7dbda7bf67f3b3eb39672e32c8e22335d3610 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/Api_4_Afv_Dltf_1.java @@ -0,0 +1,438 @@ + /** + * uicc.access.fileadministration package, deleteFile tests + * applet 1 + */ + +package uicc.test.access.fileadministration.api_4_afv_dltf; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_4_Afv_Dltf_1 extends TestToolkitApplet implements UICCConstants { + private boolean bRes; + private byte testCaseNb = -1; + + private AdminFileView uiccAdminFileView = null; + private AdminFileView adf1AdminFileView = null; + + private EditHandler editHandler; + private final short TLVHANDLER_SIZE = 50; + private byte[] data = new byte[10]; + private byte[] adf1Aid = new byte[16]; + private UICCTestConstants uiccTestConstants; + + + private byte[] createFile_EF_RFU0 = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x29, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x10, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFile_EF_RFU1 = new byte[] { + (byte) 0x82, (byte) 0x04, (byte) 0x42, (byte) 0x21, (byte) 0x00, (byte) 0x01, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2A, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x01, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + + private byte[] createFile_EF_RFU2 = new byte[] { + (byte) 0x82, (byte) 0x04, (byte) 0x46 , (byte) 0x21, (byte) 0x00, (byte) 0x03, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2B, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x03, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFile_EF_RFU0_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x41, (byte) 0x21, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x29, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x10, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + private byte[] createFile_EF_RFU1_inADF = new byte[] { + (byte) 0x82, (byte) 0x04, (byte) 0x42, (byte) 0x21, (byte) 0x00, (byte) 0x01, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2A, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x01, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + + private byte[] createFile_EF_RFU2_inADF = new byte[] { + (byte) 0x82, (byte) 0x04, (byte) 0x46 , (byte) 0x21, (byte) 0x00, (byte) 0x03, // File Descriptor + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2B, // File ID + (byte) 0x8A, (byte) 0x01, (byte) 0x05, // Life Cycle Status Information + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, // Security Attributes + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x03, // File Size + (byte) 0x88, (byte) 0x00 // Short File Identifier + }; + + + + private byte[] createFile_DF_RFU1 = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x5F, (byte) 0x01, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x50, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01,(byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFile_DF_RFU2 = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x5F, (byte) 0x02, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x50, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01,(byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFile_DF_RFU1_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x5F, (byte) 0x01, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x50, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01,(byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + private byte[] createFile_DF_RFU2_inADF = new byte[] { + (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x21, + (byte) 0x83, (byte) 0x02, (byte) 0x5F, (byte) 0x02, + (byte) 0x8A, (byte) 0x01, (byte) 0x05, + (byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01, + (byte) 0x81, (byte) 0x02, (byte) 0x00, (byte) 0x50, + (byte) 0xC6, (byte) 0x06, (byte) 0x90, (byte) 0x01,(byte) 0x80, (byte) 0x83, (byte) 0x01, (byte) 0x01 + }; + + + + /** + * Constructor of the applet + */ + public Api_4_Afv_Dltf_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_4_Afv_Dltf_1 thisApplet = new Api_4_Afv_Dltf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++testCaseNb) { + + /** Testcase 0 + * Initialization + */ + case 0: + + // Create Files to test deletion in MF + + uiccAdminFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + // Create MF/DF_TEST/DF_RFU1 + editHandler.clear(); + editHandler.appendArray(createFile_DF_RFU1, (short) 0,(short) createFile_DF_RFU1.length); + uiccAdminFileView.createFile(editHandler); + + uiccAdminFileView.select(UICCTestConstants.FID_DF_RFU1); + + // Create MF/DF_TEST/DF_RFU1/EF_RFU1 + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU1, (short) 0,(short) createFile_EF_RFU1.length); + uiccAdminFileView.createFile(editHandler); + + // Create MF/DF_TEST/DF_RFU1/EF_RFU2 + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU2, (short) 0,(short) createFile_EF_RFU2.length); + uiccAdminFileView.createFile(editHandler); + + + // Create MF/DF_TEST/DF_RFU1/DF_RFU2 + editHandler.clear(); + editHandler.appendArray(createFile_DF_RFU2, (short) 0,(short) createFile_DF_RFU2.length); + uiccAdminFileView.createFile(editHandler); + + uiccAdminFileView.select(UICCTestConstants.FID_DF_RFU2); + + // Create MF/DF_TEST/DF_RFU1/DF_RFU2/EF_RFU0 + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU0, (short) 0,(short) createFile_EF_RFU0.length); + uiccAdminFileView.createFile(editHandler); + + + // Create Files to test deletion in ADF + + adf1AdminFileView = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + + + // Create MF/DF_TEST/DF_RFU1 + editHandler.clear(); + editHandler.appendArray(createFile_DF_RFU1_inADF, (short) 0,(short) createFile_DF_RFU1_inADF.length); + adf1AdminFileView.createFile(editHandler); + adf1AdminFileView.select(UICCTestConstants.FID_DF_RFU1); + + // Create MF/DF_TEST/DF_RFU1/EF_RFU1 + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU1_inADF, (short) 0,(short) createFile_EF_RFU1_inADF.length); + adf1AdminFileView.createFile(editHandler); + + // Create MF/DF_TEST/DF_RFU1/EF_RFU2 + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU2_inADF, (short) 0,(short) createFile_EF_RFU2_inADF.length); + adf1AdminFileView.createFile(editHandler); + + // Create MF/DF_TEST/DF_RFU1/DF_RFU2 + editHandler.clear(); + editHandler.appendArray(createFile_DF_RFU2_inADF, (short) 0,(short) createFile_DF_RFU2_inADF.length); + adf1AdminFileView.createFile(editHandler); + + adf1AdminFileView.select(UICCTestConstants.FID_DF_RFU2); + + // Create MF/DF_TEST/DF_RFU1/DF_RFU2/EF_RFU0 + editHandler.clear(); + editHandler.appendArray(createFile_EF_RFU0_inADF, (short) 0,(short) createFile_EF_RFU0_inADF.length); + adf1AdminFileView.createFile(editHandler); + + break; + + + /** Testcase 1 + * Delete EF + */ + case 1: + bRes = true; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_DF_RFU1); + uiccAdminFileView.deleteFile(UICCTestConstants.FID_EF_RFU1); + } + catch (Exception e) { + bRes = false; + } + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_DF_RFU1); + uiccAdminFileView.select(UICCTestConstants.FID_EF_RFU1); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 2 + * Delete EF in ADF1 + */ + case 2: + bRes = true; + + try { + adf1AdminFileView.select(UICCTestConstants.FID_ADF); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView.select(UICCTestConstants.FID_DF_RFU1); + adf1AdminFileView.deleteFile(UICCTestConstants.FID_EF_RFU1); + } + catch (Exception e) { + bRes = false; + } + + try { + adf1AdminFileView.select(UICCTestConstants.FID_MF); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView.select(UICCTestConstants.FID_DF_RFU1); + adf1AdminFileView.select(UICCTestConstants.FID_EF_RFU1); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 3 + * Delete DF and its subtree + */ + case 3: + bRes = true; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.deleteFile(UICCTestConstants.FID_DF_RFU1); + } + catch (Exception e) { + bRes = false; + } + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_DF_RFU1); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 4 + * Delete DF and its subtree in ADF1 + */ + case 4: + bRes = true; + + try { + adf1AdminFileView.select(UICCTestConstants.FID_ADF); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView.deleteFile(UICCTestConstants.FID_DF_RFU1); + } + catch (Exception e) { + bRes = false; + } + + try { + adf1AdminFileView.select(UICCTestConstants.FID_MF); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView.select(UICCTestConstants.FID_DF_RFU1); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 5 + * File not found + */ + case 5: + bRes = false; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.deleteFile(UICCTestConstants.FID_DF_RFU1); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + try { + adf1AdminFileView.select(UICCTestConstants.FID_MF); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + adf1AdminFileView.deleteFile(UICCTestConstants.FID_DF_RFU1); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 6 + * Security status not satisfied + */ + case 6: + bRes = false; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_DF_ARR2); + uiccAdminFileView.deleteFile(UICCTestConstants.FID_EF_TAR2T); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + break; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/Test_Api_4_Afv_Dltf.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/Test_Api_4_Afv_Dltf.java new file mode 100644 index 0000000000000000000000000000000000000000..111b34d7aaa9cb923c1683052fb50dd8ca5fd886 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/Test_Api_4_Afv_Dltf.java @@ -0,0 +1,105 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access.fileadministration package part 4 + * Test source for deleteFile tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_dltf; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_4_Afv_Dltf extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_dltf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_4_Afv_Dltf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** test cases 0, 1, 2, 3, 4, 5, 6 + * 0. Initialization + * 1. Delete EF + * 2. Delete EF in ADF1 + * 3. Delete DF and its subtree + * 4. Delete DF and its subtree in ADF1 + * 5. File Not found + * 6. Security status not found + */ + + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + + + /** + * Check Results and delete packages + */ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "06CCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4491267bc3c39802d98be866f71d441acf1bb94a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_dltf.Api_4_Afv_Dltf_1 +uicc.test.access.fileadministration.api_4_afv_dltf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/javacard/api_4_afv_dltf.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/javacard/api_4_afv_dltf.cap new file mode 100644 index 0000000000000000000000000000000000000000..b7d1f14e2296b77c9f8d6cd6fa98914b3ee09a21 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_dltf/javacard/api_4_afv_dltf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/Api_4_Afv_Incr_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/Api_4_Afv_Incr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..4229c61767d0d64c8aebcb649dd8ddf2d7ee2a39 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/Api_4_Afv_Incr_1.java @@ -0,0 +1,579 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Incr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_incr; + +import uicc.system.HandlerBuilder; +import uicc.test.util.* ; +import uicc.toolkit.ViewHandler; +import javacard.framework.*; +import uicc.access.* ; +import uicc.access.fileadministration.*; + + +public class Api_4_Afv_Incr_1 extends TestToolkitApplet implements UICCConstants +{ + private AdminFileView UiccFileView = null; + private AdminFileView UiccAdminFileView = null; + private ViewHandler createEFCmd = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private byte [] abCreateEF = { + (byte)0x82,(byte)0x04, // Tag, Length - File descriptor + (byte)0x46,(byte)0x21,(byte)0x00,(byte)0x7F, // Value - File descriptor (Cyclic) and record length (0x7F) + (byte)0x83,(byte)0x02, // Tag, Length - File Id + (byte)0x2C,(byte)0x7F, // Value - File Id + (byte)0x8A,(byte)0x01,(byte)0x05, // Tag, Length, Value - LCSI (Activated) + (byte)0x8B,(byte)0x03, // Tag, Length - Security attribute + (byte)0x2F,(byte)0x06,(byte)0x01, // Value - Security attribute (EF Arr, record nb) + (byte)0x80,(byte)0x02,(byte)0x00,(byte)0x7F, // Tag, Length, value - File size (0 bytes => no record) + (byte)0x88,(byte)0x00}; // Tag, Length - SFI (no SFI) + byte testCaseNb = (byte) 0x00; + byte incr[] = null; + byte resp[] = null; + byte data[] = null; + byte comp[] = null; + short incrOffset = 0; + short respOffset = 0; + short incrLength = 0; + short respLength = 0; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Incr_1() + { + incr = new byte[4]; + resp = new byte[4]; + comp = new byte[4]; + data = new byte[3]; + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Incr_1 thisApplet = new Api_4_Afv_Incr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + UiccAdminFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + incrLength = 2; + UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : increase , verify response + // ----------------------------------------------------------------- + testCaseNb = 2; + UiccFileView.select((short)UICCTestConstants.FID_EF_CARU); + try + { + // Set records to 00 00 00 + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incr[2] = (byte)1; + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + + // Verify result + Util.arrayFillNonAtomic(comp, (short)0, (short)comp.length, (byte)0); + comp[2] = (byte)1; + if ((respLength == (short)3) && + (Util.arrayCompare(resp, (short)0, comp, (short)0, (short)4) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : increase , verify file + // ----------------------------------------------------------------- + testCaseNb = 3; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incr[3] = (byte)2; + incrOffset = 1; + incrLength = 3; + respOffset = 1; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + + // Verify result + Util.arrayFillNonAtomic(resp, (short)0, (short)resp.length, (byte)0); + Util.arrayFillNonAtomic(comp, (short)0, (short)comp.length, (byte)0); + comp[2] = (byte)3; + UiccFileView.readRecord((short)0, REC_ACC_MODE_CURRENT, (short)0, resp, (short)0, (short)3); + if ((respLength == (short)3) && + (Util.arrayCompare(resp, (short)0, comp, (short)0, (short)4) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : incr[] is null + // ----------------------------------------------------------------- + testCaseNb = 4; + try + { + // increase + incrOffset = 0; + incrLength = 1; + respOffset = 0; + respLength = UiccFileView.increase(null, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 5 : incrLength < 0 + // ----------------------------------------------------------------- + testCaseNb = 5; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = -1; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6 : incrOffset < 0 + // ----------------------------------------------------------------- + testCaseNb = 6; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = -1; + incrLength = 1; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7 : IncrOffset + incrLength > incr.length + // ----------------------------------------------------------------- + testCaseNb = 7; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 1; + incrLength = 4; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 8 : Reach Maximum Value + // ----------------------------------------------------------------- + testCaseNb = 8; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0xFF); + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.MAX_VALUE_REACHED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + + try + { + // Set records to FF FF FF + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0xFF); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incr[2] = (byte)1; + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.MAX_VALUE_REACHED) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 9 : resp[] is null + // ----------------------------------------------------------------- + testCaseNb = 9; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0xFF); + incrOffset = 0; + incrLength = 1; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, null, respOffset); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 10 : incrLength < 0 + // ----------------------------------------------------------------- + testCaseNb = 10; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = 1; + respOffset = -1; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 11 : respOffset + recordLength > resp.length + // ----------------------------------------------------------------- + testCaseNb = 11; + try + { + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = 3; + respOffset = 2; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 12 : Ef is not cyclic + // ----------------------------------------------------------------- + testCaseNb = 12; + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_TARU); + incr = new byte[3]; + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.COMMAND_INCOMPATIBLE) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_LARU); + // increase + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.COMMAND_INCOMPATIBLE) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 13 : Access condition not fulfilled + // ----------------------------------------------------------------- + testCaseNb = 13; + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_CNIC); + // increase + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 14 : EF is deactivated + // ----------------------------------------------------------------- + testCaseNb = 14; + try + { + UiccFileView.select((short)UICCTestConstants.FID_EF_CARU); + // deactivated + UiccFileView.deactivateFile(); + // increase + incrOffset = 0; + incrLength = 3; + respOffset = 0; + respLength = UiccFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.REF_DATA_INVALIDATED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + // activate + UiccFileView.activateFile(); + // Restore Ef content + // Set records to 55 55 55 + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0x55); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + // Set records to AA AA AA + Util.arrayFillNonAtomic(data, (short)0, (short)data.length, (byte)0xAA); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, data, (short)0, (short)data.length); + bRes &= true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 15 : incrLength out of range + // ----------------------------------------------------------------- + testCaseNb = 15; + try + { + // Create EF 0x2CFD + incr = new byte[128]; + resp = new byte[0xFF]; + comp = new byte[0xFF]; + createEFCmd = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, (short)abCreateEF.length, abCreateEF, (short)0x00, (short)abCreateEF.length); + UiccAdminFileView.createFile(createEFCmd); + UiccAdminFileView.select((short)0x2C7F); + + Util.arrayFillNonAtomic(comp, (short)0, (short)127, (byte)0xFF); + comp[0] = (byte)0x00; + UiccAdminFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, comp, (short)0, (short)127); + // increase + Util.arrayFillNonAtomic(incr, (short)0, (short)incr.length, (byte)0); + Util.arrayFillNonAtomic(resp, (short)0, (short)resp.length, (byte)0); + Util.arrayFillNonAtomic(comp, (short)0, (short)resp.length, (byte)0); + incr[127] = (byte)0x01; + comp[0] = (byte)0x01; + incrOffset = 1; + incrLength = 127; + respOffset = 0; + respLength = UiccAdminFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + // Check result + if ((respLength == (short)0x7F) && + (Util.arrayCompare(resp, (short)0, comp, (short)0, respLength) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + // increase + incrOffset = 0; + incrLength = 128; + respOffset = 0; + respLength = UiccAdminFileView.increase(incr, incrOffset, incrLength, resp, respOffset); + bRes = false; + } + catch (Exception e) + { + bRes &= true; + } + reportTestOutcome(testCaseNb, bRes); + UiccAdminFileView.deleteFile((short)0x2C7F); + + incr = null; + resp = null; + comp = null; + data = null; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/Test_Api_4_Afv_Incr.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/Test_Api_4_Afv_Incr.java new file mode 100644 index 0000000000000000000000000000000000000000..08bfeef0e42478193c021b7ef6c37931917784f6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/Test_Api_4_Afv_Incr.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_incr; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Incr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_incr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Incr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" ); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0F" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..448a201cab2e1b0f7fbf1f22ed538c2145ad74ff --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_incr.Api_4_Afv_Incr_1 +uicc.test.access.fileadministration.api_4_afv_incr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/javacard/api_4_afv_incr.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/javacard/api_4_afv_incr.cap new file mode 100644 index 0000000000000000000000000000000000000000..4aee2f6ebcabe8c992dbf712080daf14aaea16e3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_incr/javacard/api_4_afv_incr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/Api_4_Afv_Redb_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/Api_4_Afv_Redb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6d93b75139cffc24cb0aeb8e21216994d1b9c30d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/Api_4_Afv_Redb_1.java @@ -0,0 +1,363 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Redb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_redb; + +import javacard.framework.*; +import uicc.access.*; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_redb + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ + +public class Api_4_Afv_Redb_1 extends TestToolkitApplet implements UICCConstants +{ + private AdminFileView UiccFileView = null; + + final short RESP_BUFFER_LENGTH = (short)0x0104; + + byte[] resp = new byte[RESP_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[RESP_BUFFER_LENGTH]; + byte[] nullBuffer = null; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Redb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Redb_1 thisApplet = new Api_4_Afv_Redb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short result = 0; + short respOffset = 0; + short respLength = 0; + short fileOffset = 0; + + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TEST CASE 01: Read from a transparent file at offset 0 + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + + fileOffset = 0; + respOffset = 10; + respLength = 250; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0xFF); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)10,(byte)0x55); + // Initialise resp buffer + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0x55); + + // Call the readBinary() method + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 02: Read from a transparent file at a given offset + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + try { + + fileOffset = (short)0x80; + respOffset = (short)0x80; + respLength = 5; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)respOffset,(short)respLength,(byte)0xFF); + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Errorcase, fileOffset is negative + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + fileOffset = (short)-1; + respOffset = 0; + respLength = 10; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Errorcase, fileOffset + respLength > EF length + *------------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + fileOffset = (short)259; + respOffset = 0; + respLength = 2; + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Errorcase, resp is null + *------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + fileOffset = 0; + respOffset = 0; + respLength = 10; + result = UiccFileView.readBinary(fileOffset, nullBuffer, respOffset, respLength); + bRes = false; + } + catch (NullPointerException npe) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 06: Errorcase, respOffset < 0 + *-------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + fileOffset = 0; + respOffset = (short)-1; + respLength = 10; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 07: Errorcase, respLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + fileOffset = 0; + respOffset = 0; + respLength = (short)-1; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 08: Errorcase, respOffset + respLength > resp.Length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + fileOffset = 0; + respOffset = 0xFA; + respLength = 0x0B; + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 09: Errorcase, EF is not transparent + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + fileOffset = 0; + respOffset = 0; + respLength = 1; + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Errorcase, Access condition not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TNR); + + fileOffset = 0; + respOffset = 0; + respLength = 1; + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Errorcase, EF is invalidated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_TNU); + UiccFileView.deactivateFile(); + + try { + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + + reportTestOutcome(testCaseNb,bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + + result = UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/Test_Api_4_Afv_Redb.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/Test_Api_4_Afv_Redb.java new file mode 100644 index 0000000000000000000000000000000000000000..b9ef8241b2eef81c5ecff33b7c4d95aef765f43a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/Test_Api_4_Afv_Redb.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Tvw_Redb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_redb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_redb + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_4_Afv_Redb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_redb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Redb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession("0101"); + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5c59b22afa3831f8b97b766d53024dbb4fd1f276 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_redb.Api_4_Afv_Redb_1 +uicc.test.access.fileadministration.api_4_afv_redb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/javacard/api_4_afv_redb.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/javacard/api_4_afv_redb.cap new file mode 100644 index 0000000000000000000000000000000000000000..532ede7b1f486d9da33e2121b6f98a14ad18ea34 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redb/javacard/api_4_afv_redb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/Api_4_Afv_Redr_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/Api_4_Afv_Redr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..8cd09eede5f436e492a62885d1c7ca53270d5047 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/Api_4_Afv_Redr_1.java @@ -0,0 +1,853 @@ +//----------------------------------------------------------------------------- +//Api_4_Afv_Redr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_redr; + +import javacard.framework.*; +import uicc.access.*; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.api_4_Afv_redr + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_4_Afv_Redr_1 extends TestToolkitApplet implements UICCConstants +{ + private AdminFileView UiccFileView = null; + + final short RESP_BUFFER_LENGTH = (short)0x14; + + byte[] resp = new byte[RESP_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[RESP_BUFFER_LENGTH]; + byte[] nullBuffer = null; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Redr_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Redr_1 thisApplet = new Api_4_Afv_Redr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short result = 0; + short respOffset = 0; + short respLength = 0; + short fileOffset = 0; + short recOffset = 0; + byte recNumber = 0; + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*----------------------------------------------------------------------------------- + * TEST CASE 01: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + recNumber = 1; + respOffset = 0; + respLength = 0x0A; + + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + /*---------------------------------------------------------------- + * TEST CASE 02: Read Absolute from a linear fixed file + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Test case 1.1: Record pointer not set + recNumber = 2; + respOffset = 0; + respLength = 0x04; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0x55); + // Initialise resp buffer + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0x00); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Test case 1.2 : read record in next mode + recNumber = 0; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0xAA); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Read current from linear fixed EF + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Read next from a linear fixed file + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Select EF LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0xAA); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Read next from linear fixed EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 06: Read previous from linear fixed EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Select EF LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Call the readRecord() method to set the record pointer to the first record + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)4,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 07: Read previous from a linear fixed file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + recNumber = 0; + respOffset = 0; + respLength = 0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 08: Read absolute from Cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + // Read record 2 + recNumber = 2; + respOffset = 0; + respLength = 0x03; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0x00); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + // Initialise the resp buffer + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0x00); + + // Select EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Read record 1 + recNumber = 1; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Call the readRecord() method in NEXT mode to set the record pointer + recNumber = 0; + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: Read current from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Read next from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Read Next from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Select EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Read previous from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 13: Read previous from cyclic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0D; + bRes = false; + try { + recNumber = 0; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0x55); + + if (result == (short)(respOffset + respLength)) + bRes = true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + // Select EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,resp,respOffset,respLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)3,(byte)0xAA); + + if (result == (short)(respOffset + respLength)) + bRes &= true; + + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, RESP_BUFFER_LENGTH) == 0) + bRes &= true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 14: Read absolute from linear fixed beyond record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0E; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + respLength = (short)0x04; + + try { + recNumber = (short)-1; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)3; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 15: Read current from linear fixed file with no current record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0F; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)0; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 16: Read absolute with recOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x10; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)1; + recOffset = (short)-1; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 17: Read absolute with recOffset + respLength > record length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x11; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)0x01; + recOffset = (short)0x02; + respLength = (short)0x04; + + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 18: Read with invalid mode + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x12; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + recNumber = (short)0x00; + recOffset = (short)0x00; + respLength = (short)0x04; + + try { + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,(byte)1,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + try { + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,(byte)5,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 19: resp buffer is null + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x13; + bRes = false; + + try { + recNumber = 1; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,null,respOffset,respLength); + bRes = false; + } + catch(NullPointerException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 20: respOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x14; + bRes = false; + + try { + recNumber = 1; + respOffset = (short)-1; + respLength = 4; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 21: respLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x15; + bRes = false; + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)-1; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 22: respLength + respOffset > resp.length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x16; + bRes = false; + + try { + recNumber = 1; + respOffset = (short)0x11; + respLength = (short)4; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 23: EF is not a record file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x17; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)4; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 24: Access not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x18; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CNR); + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)3; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 25: EF is deactivated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x19; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CNU); + UiccFileView.deactivateFile(); + + try { + recNumber = 1; + respOffset = (short)0; + respLength = (short)3; + // Call the readRecord() method + result = UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,resp,respOffset,respLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + reportTestOutcome(testCaseNb,bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/Test_Api_4_Afv_Redr.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/Test_Api_4_Afv_Redr.java new file mode 100644 index 0000000000000000000000000000000000000000..fe741603cb7f262c48f152772c105b55e83ade78 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/Test_Api_4_Afv_Redr.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Fvw_Redr.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_redr; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_redr + * + * @version 0.0.1 - 6 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_4_Afv_Redr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_redr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Redr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "19CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession("0101"); + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c50617f32f94291ffdadd3526d401c8485a738e3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_redr.Api_4_Afv_Redr_1 +uicc.test.access.fileadministration.api_4_afv_redr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/javacard/api_4_afv_redr.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/javacard/api_4_afv_redr.cap new file mode 100644 index 0000000000000000000000000000000000000000..d939e3640500759cd3bc94ee6b5b2cec5247a821 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_redr/javacard/api_4_afv_redr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/Api_4_Afv_Rszf_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/Api_4_Afv_Rszf_1.java new file mode 100644 index 0000000000000000000000000000000000000000..eb51d828b36fb58db06d8fb0fef44847c21fdc7f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/Api_4_Afv_Rszf_1.java @@ -0,0 +1,316 @@ +/** + * uicc.access.fileadministration package, resizeFile tests + * applet 1 + */ + +package uicc.test.access.fileadministration.api_4_afv_rszf; + + +import javacard.framework.*; + +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.system.*; +import uicc.test.util.*; +import uicc.toolkit.*; + + +public class Api_4_Afv_Rszf_1 extends TestToolkitApplet implements UICCConstants { + private boolean bRes; + private byte testCaseNb = 0; + + private AdminFileView uiccAdminFileView = null; + private AdminFileView adf1AdminFileView = null; + + private EditHandler editHandler; + private final short TLVHANDLER_SIZE = 50; + private byte[] adf1Aid = new byte[16]; + private UICCTestConstants uiccTestConstants; + + + private byte[] resizeFile_EF_TARU = new byte[] { + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x03, + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x0A + }; + + private byte[] resizeFile_EF_LARU = new byte[] { + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x0C, + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x10 + }; + + private byte[] incorrectParameters = new byte[] { + (byte) 0x42, (byte) 0x42, (byte) 0x42, (byte) 0x42 + }; + + private byte[] resizeFile_FileNotFound = new byte[] { + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x2A, + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x0A + }; + + private byte[] resizeFile_SecurityStatusNotSatisfied = new byte[] { + (byte) 0x83, (byte) 0x02, (byte) 0x4F, (byte) 0x12, + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x0A + }; + + private byte[] resizeFile_CommandIncompatible = new byte[] { + (byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x09, + (byte) 0x80, (byte) 0x02, (byte) 0x00, (byte) 0x10 + }; + + + + /** + * Constructor of the applet + */ + public Api_4_Afv_Rszf_1() { + editHandler = (EditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, + (short) TLVHANDLER_SIZE); + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1, (short) 0, adf1Aid, (short) 0, + (short) adf1Aid.length); + } + + + /** + * Method called by the JCRE at the installation of the applet + * + * @param bArray + * @param bOffset + * @param bLength + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance + Api_4_Afv_Rszf_1 thisApplet = new Api_4_Afv_Rszf_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + + /** + * Method called by the CAT RE + * + * @param event + */ + public void processToolkit(short event) { + switch (++testCaseNb) { + + /** Testcase 1 + * Resize a transparent EF + */ + case 1: + bRes = true; + + try { + uiccAdminFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(resizeFile_EF_TARU, (short) 0,(short) resizeFile_EF_TARU.length); + uiccAdminFileView.resizeFile(editHandler); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 2 + * Resize a linear fixed EF + */ + case 2: + bRes = true; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(resizeFile_EF_LARU, (short) 0,(short) resizeFile_EF_LARU.length); + uiccAdminFileView.resizeFile(editHandler); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 3 + * Call resizeFile with a null viewHandler + */ + case 3: + bRes = false; + + try { + uiccAdminFileView.resizeFile(null); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 4 + * Call resizeFile with incorrect parameters + */ + case 4: + bRes = false; + + try { + editHandler.clear(); + editHandler.appendArray(incorrectParameters, (short) 0,(short) incorrectParameters.length); + uiccAdminFileView.resizeFile(editHandler); + } + catch (AdminException e) { + bRes = (e.getReason() == AdminException.INCORRECT_PARAMETERS); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 5 + * File not found + */ + case 5: + bRes = false; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(resizeFile_FileNotFound, (short) 0,(short) resizeFile_FileNotFound.length); + uiccAdminFileView.resizeFile(editHandler); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + try { + adf1AdminFileView = AdminFileViewBuilder.getTheAdminFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.CLEAR_ON_RESET); + adf1AdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(resizeFile_FileNotFound, (short) 0,(short) resizeFile_FileNotFound.length); + adf1AdminFileView.resizeFile(editHandler); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.FILE_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 6 + * Security Status not satisfied + */ + case 6: + bRes = false; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_DF_ARR2); + + editHandler.clear(); + editHandler.appendArray(resizeFile_SecurityStatusNotSatisfied, (short) 0,(short) resizeFile_SecurityStatusNotSatisfied.length); + uiccAdminFileView.resizeFile(editHandler); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + + /** Testcase 7 + * Command incompatible + */ + case 7: + bRes = false; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + + editHandler.clear(); + editHandler.appendArray(resizeFile_CommandIncompatible, (short) 0,(short) resizeFile_CommandIncompatible.length); + uiccAdminFileView.resizeFile(editHandler); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 8 + * Invalidated data + */ + case 8: + bRes = false; + + try { + uiccAdminFileView.select(UICCTestConstants.FID_MF); + uiccAdminFileView.select(UICCTestConstants.FID_DF_TEST); + uiccAdminFileView.select(UICCTestConstants.FID_EF_TARU); + uiccAdminFileView.deactivateFile(); + + editHandler.clear(); + editHandler.appendArray(resizeFile_EF_TARU, (short) 0,(short) resizeFile_EF_TARU.length); + uiccAdminFileView.resizeFile(editHandler); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + uiccAdminFileView.activateFile(); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + break; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/Test_Api_4_Afv_Rszf.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/Test_Api_4_Afv_Rszf.java new file mode 100644 index 0000000000000000000000000000000000000000..4dffe70176ba5a4795df31554deb8fe1093d2263 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/Test_Api_4_Afv_Rszf.java @@ -0,0 +1,154 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.access.fileadministration package part 4 + * Test source for resizeFile tests + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_rszf; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_4_Afv_Rszf extends UiccTestModel { + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_rszf"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + static final String DF_TELECOM = "7F10"; + static final String MF = "3F00"; + static final String DF_TEST = "7F4A"; + static final String EF_TNR = "6F01"; + static final String EF_TNU = "6F02"; + static final String EF_TARU = "6F03"; + static final String EF_CNR = "6F04"; + static final String EF_CARU = "6F09"; + static final String EF_LNU = "6F0B"; + static final String EF_LARU = "6F0C"; + static final String EF_TDAC = "6F0F"; + static final String EF_LUPC = "6F18"; + static final String EF_NOSH = "6F1B"; + static final String EF_RFU0 = "6F29"; + static final String EF_RFU1 = "6F2A"; + static final String EF_RFU2 = "6F2B"; + static final String DF_RFU1 = "5F01"; + static final String DF_RFU2 = "5F02"; + static final String DF_RFU3 = "5F03"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_4_Afv_Rszf() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00" + // LV ADF1 access domain DAP + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + + /** test case 1 + * Resize a transparent EF + */ + + test.unrecognizedEnvelope(); + + test.selectFile(MF); + test.selectFile(DF_TEST); + response = test.selectFile(EF_TARU); + + result &= (response.getData().indexOf("8002000A") != -1); + + test.resizeFile(EF_TARU, "0104"); + + + /** test case 2 + * Resize a Linear Fixed EF + */ + + test.unrecognizedEnvelope(); + + test.selectFile(MF); + test.selectFile(DF_TEST); + response = test.selectFile(EF_LARU); + + result &= (response.getData().indexOf("80020010") != -1); + + test.resizeFile(EF_LARU, "08"); + + + /** test cases 3, 4, 5, 6, 7, 8, 9 + * 3. Call resizeFile with a null viewHandler + * 4. Call resizeFile with incorrect parameters + * 5. File not found + * 6. Security status not satisfied + * 7. Command incompatible + * 8. Invalidated data + */ + + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + test.unrecognizedEnvelope(); + + + /** + * Check Results and delete packages + */ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "08CCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..727aff7ec74b754a8119b1eb72a9e8f747f2c701 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_rszf.Api_4_Afv_Rszf_1 +uicc.test.access.fileadministration.api_4_afv_rszf +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/javacard/api_4_afv_rszf.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/javacard/api_4_afv_rszf.cap new file mode 100644 index 0000000000000000000000000000000000000000..bede232369711cdd24d23875e8b4d8763bb37f0a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_rszf/javacard/api_4_afv_rszf.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/Api_4_Afv_Sear_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/Api_4_Afv_Sear_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d1bb4dc33c4632e403f86e60e07db7c6e8b1b350 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/Api_4_Afv_Sear_1.java @@ -0,0 +1,1842 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Sear_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_sear; + +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.* ; + + +public class Api_4_Afv_Sear_1 extends TestToolkitApplet implements UICCConstants +{ + private AdminFileView UiccFileView = null; + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private byte[] RecValue1 = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08, + (byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + private byte[] RecValue2 = {(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x01,(byte)0x02, + (byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09}; + private byte[] RecValue3 = {(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B, + (byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x01,(byte)0x02,(byte)0x03}; + private byte[] RecValue4 = {(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06}; + private byte[] RecValue5 = {(byte)0x0A,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x0B,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x0C,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x0D,(byte)0x01,(byte)0x02}; + private byte[] RecValue6 = {(byte)0x03,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x02, + (byte)0x01,(byte)0x03,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x02,(byte)0x01}; + + byte testCaseNb = (byte) 0x00; + byte patt[] = null; + short resp[] = null; + short comp[] = null; + byte mode = 0; + short recordNumber = 0; + short searchIndication = 0; + short pattOffset = 0; + short respOffset = 0; + short pattLength = 0; + short respLength = 0; + short nbRecFound = 0; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Sear_1() + { + comp = new short[5]; + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Sear_1 thisApplet = new Api_4_Afv_Sear_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + // ----------------------------------------------------------------- + // Test Case 1 : No EF Selected + // ----------------------------------------------------------------- + testCaseNb = 1; + UiccFileView.select((short)UICCTestConstants.FID_DF_TEST); + try + { + // searchRecord + patt = new byte[3]; + resp = new short[4]; + Util.arrayFillNonAtomic(patt, (short)0, (short)patt.length, (byte)0xAA); + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == (short)UICCException.NO_EF_SELECTED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // -- Fixed linear EF + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + + + // ----------------------------------------------------------------- + // Test Case 2 : Simple mode search forward + // ----------------------------------------------------------------- + testCaseNb = 2; + UiccFileView.select((short)UICCTestConstants.FID_EF_LSEA); + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + patt[0] = (byte)0x10; + patt[1] = (byte)0x03; + patt[2] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 4; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)2; + comp[2] = (short)4; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)2; + comp[2] = (short)4; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Simple mode search backward + // ----------------------------------------------------------------- + testCaseNb = 3; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + patt[0] = (byte)0x08; + patt[1] = (byte)0x0A; + patt[2] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 2; + respLength = 2; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + patt = new byte[4]; + patt[0] = (byte)0x08; + patt[1] = (byte)0x09; + patt[2] = (byte)0x0A; + patt[3] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 6; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)1; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + patt = new byte[4]; + patt[0] = (byte)0x08; + patt[1] = (byte)0x09; + patt[2] = (byte)0x0A; + patt[3] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)1; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // --------------------------------------------------------------------------------------------------- + // Test Case 4 : Enhanced Mode, search backward from previous record, start search at offset in record + // --------------------------------------------------------------------------------------------------- + testCaseNb = 4; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0009; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + patt[3] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x03; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0000; + recordNumber = 0; + pattOffset = 0; + pattLength = 5; + respOffset = 2; + respLength = 2; + patt = new byte[6]; + patt[0] = (byte)0x0C; + patt[1] = (byte)0x0D; + patt[2] = (byte)0x0E; + patt[3] = (byte)0x0F; + patt[4] = (byte)0x01; + patt[5] = (byte)0x02; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (byte)0x02; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------------------------------------- + // Test Case 5 : Enhanced Mode, search backward from previous record, start search at value in record + // -------------------------------------------------------------------------------------------------- + testCaseNb = 5; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0810; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt = new byte[4]; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + patt[3] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // 3 readRecord() to set record pointer to record 5 + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)4); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)4); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)4); + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x080E; + recordNumber = 0; + pattOffset = 3; + pattLength = 1; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + patt[3] = (byte)0x04; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x04; + comp[1] = (byte)0x02; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------------------------------------- + // Test Case 6 : Enhanced Mode, search backward from previous given record, start at offset in record + // -------------------------------------------------------------------------------------------------- + testCaseNb = 6; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0000; + recordNumber = 1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 4; + patt = new byte[3]; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x01; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0004; + recordNumber = 6; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)5; + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)2; + if ((nbRecFound == (short)4) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ------------------------------------------------------------------------------------------------- + // Test Case 7 : Enhanced Mode, search backward from previous given record, start at value in record + // ------------------------------------------------------------------------------------------------- + testCaseNb = 7; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x080D; + recordNumber = 1; + pattOffset = 1; + pattLength = 1; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x0E; + patt[1] = (byte)0x0E; + patt[2] = (byte)0x0E; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x01; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0800; + recordNumber = 6; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // --------------------------------------------------------------------------------------- + // Test Case 8 : Enhanced Mode, search forward from next record, start at offset in record + // --------------------------------------------------------------------------------------- + testCaseNb = 8; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0003; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + patt[0] = (byte)0x00; + patt[1] = (byte)0x0A; + patt[2] = (byte)0x0B; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (short) 3; + comp[3] = (short) 4; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0003; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 0; + respLength = 4; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short) 4; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------------------------- + // Test Case 9 : Enhanced Mode, search forward from next record, start at value in record + // -------------------------------------------------------------------------------------- + testCaseNb = 9; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0804; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0801; + recordNumber = 0; + pattOffset = 2; + pattLength = 1; + respOffset = 0; + respLength = 4; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short) 5; + comp[1] = (short) 6; + if ((nbRecFound == (short)2) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ---------------------------------------------------------------------------------------------- + // Test Case 10 : Enhanced Mode, search forward from next given record, start at offset in record + // ---------------------------------------------------------------------------------------------- + testCaseNb = 10; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x0007; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 1; + respLength = 3; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[1] = (short)3; + comp[2] = (short)4; + comp[3] = (short)5; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x000C; + recordNumber = 3; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x03; + patt[1] = (byte)0x02; + patt[2] = (byte)0x01; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x06; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // --------------------------------------------------------------------------------------------- + // Test Case 11 : Enhanced Mode, search forward from next given record, start at value in record + // --------------------------------------------------------------------------------------------- + testCaseNb = 11; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x080D; + recordNumber = 5; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x080C; + recordNumber = 5; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (byte)0x05; + if ((nbRecFound == (short)1) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ---------------------------------------------------------------------------- + // Test Case 12 : Simple mode, total number of found patterns exceed response[] + // ---------------------------------------------------------------------------- + testCaseNb = 12; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)1; + comp[1] = (short)2; + comp[2] = (short)3; + comp[3] = (short)4; + if ((nbRecFound == (short)4) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 4; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + resp = new short[5]; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)1; + comp[1] = (short)2; + comp[2] = (short)3; + comp[3] = (short)4; + if ((nbRecFound == (short)4) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 13 : Invalid mode + // ----------------------------------------------------------------- + testCaseNb = 13; + try + { + // searchRecord + mode = (byte)0x14; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.INVALID_MODE) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 14 : Pattern array is null + // ----------------------------------------------------------------- + testCaseNb = 14; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 2; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, null, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 15 : Response array is null + // ----------------------------------------------------------------- + testCaseNb = 15; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, null, respOffset, respLength); + bRes = false; + } + catch (NullPointerException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 16 : pattOffset<0 + // ----------------------------------------------------------------- + testCaseNb = 16; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = -1; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 17 : pattLength<0 + // ----------------------------------------------------------------- + testCaseNb = 17; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = -1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 18 : respOffset<0 + // ----------------------------------------------------------------- + testCaseNb = 18; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = -1; + respLength = 4; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 19 : respLength<0 + // ----------------------------------------------------------------- + testCaseNb = 19; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = -1; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 20 : PattOffset + pattLength > patt[] + // ----------------------------------------------------------------- + testCaseNb = 20; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 2; + respOffset = 1; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 21 : respOffset + respLength > resp[] + // ----------------------------------------------------------------- + testCaseNb = 21; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 0; + pattOffset = 0; + pattLength = 1; + respOffset = 3; + respLength = 3; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) + { + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 22 : recordNum < 0 + // ----------------------------------------------------------------- + testCaseNb = 22; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = -1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.RECORD_NOT_FOUND) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 23 : RecordNum > total number of file records + // ----------------------------------------------------------------- + testCaseNb = 23; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 7; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.RECORD_NOT_FOUND) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 24 : pattlength > record length + // ----------------------------------------------------------------- + testCaseNb = 24; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + patt = new byte[16]; + Util.arrayFillNonAtomic(patt, (short)0, (short)patt.length, (byte)0x55); + recordNumber = 3; + pattOffset = 0; + pattLength = 16; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x000E; + recordNumber = 3; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + patt = new byte[3]; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 25 : Wrong file structure + // ----------------------------------------------------------------- + testCaseNb = 25; + try + { + // Select EF TDAC + UiccFileView.select((short)UICCTestConstants.FID_EF_TDAC); + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.COMMAND_INCOMPATIBLE) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 26 : Security status not satisfied + // ----------------------------------------------------------------- + testCaseNb = 26; + try + { + // Select EF LNR + UiccFileView.select((short)UICCTestConstants.FID_EF_LNR); + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 27 : File deactivated + // ----------------------------------------------------------------- + testCaseNb = 27; + try + { + // Select EF LARU and deactivate it + UiccFileView.select((short)UICCTestConstants.FID_EF_LARU); + UiccFileView.deactivateFile(); + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 3; + respOffset = 0; + respLength = 5; + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + bRes = false; + } + catch (UICCException e) + { + if (e.getReason() == UICCException.REF_DATA_INVALIDATED) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + // Re active EF LARU + UiccFileView.activateFile(); + + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // -- Cyclic EF + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + + + // ----------------------------------------------------------------- + // Test Case 28 : Simple mode search forward + // ----------------------------------------------------------------- + testCaseNb = 28; + try + { + // Select EF CSEA + UiccFileView.select((short)UICCTestConstants.FID_EF_CSEA); + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 1; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x10; + patt[1] = (byte)0x03; + patt[2] = (byte)0x04; + resp = new short[5]; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)3) + { + comp[2] = (short)2; + comp[3] = (short)4; + comp[4] = (short)1; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)2) + { + comp[2] = (short)2; + comp[3] = (short)4; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + + // Update record in previous mode to set pointer 1 to previous record 6 + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue6, (short)0, (short)RecValue6.length); + + // searchRecord + mode = SIMPLE_SEARCH_START_FORWARD; + searchIndication = 0; + recordNumber = 2; + pattOffset = 1; + pattLength = 2; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (short)2; + comp[3] = (short)3; + comp[4] = (short)5; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes &= true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 29 : Simple mode search backward + // ----------------------------------------------------------------- + testCaseNb = 29; + try + { + // searchRecord + mode = SIMPLE_SEARCH_START_BACKWARD; + searchIndication = 0; + recordNumber = 3; + pattOffset = 1; + pattLength = 2; + respOffset = 1; + respLength = 4; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)3) + { + comp[1] = (short)3; + comp[2] = (short)2; + comp[3] = (short)5; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)2) + { + comp[1] = (short)3; + comp[2] = (short)2; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 30 : Enhanced mode, search forward, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 30; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0009; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[2] = (short)4; + comp[3] = (short)5; + comp[4] = (short)6; + if ((nbRecFound == (short)3) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 31 : Enhanced mode, search forward, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 31; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT + (short)0x0810; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + recordNumber = 0; + pattOffset = 0; + pattLength = 3; + respOffset = 2; + respLength = 3; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0x00); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if ((nbRecFound == (short)0) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 32 : Enhanced mode, search forward given record, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 32; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x0005; + recordNumber = 3; + pattOffset = 0; + pattLength = 1; + respOffset = 0; + respLength = 5; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)5) + { + comp[0] = (short)3; + comp[1] = (short)4; + comp[2] = (short)5; + comp[3] = (short)6; + comp[4] = (short)1; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)4) + { + comp[0] = (short)3; + comp[1] = (short)4; + comp[2] = (short)5; + comp[3] = (short)6; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 33 : Enhanced mode, search forward given record, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 33; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_FORWARD_FROM_NEXT_GR + (short)0x0805; + recordNumber = 6; + pattOffset = 0; + pattLength = 2; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x0E; + patt[1] = (byte)0x0F; + patt[2] = (byte)0x00; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)2) + { + comp[0] = (short)2; + comp[1] = (short)4; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)0) + { + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + + // 5 Update record in previous mode to set pointer 1 its initial value + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue5, (short)0, (short)RecValue5.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue4, (short)0, (short)RecValue4.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue3, (short)0, (short)RecValue3.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue2, (short)0, (short)RecValue2.length); + UiccFileView.updateRecord((short)0, REC_ACC_MODE_PREVIOUS, (short)0, RecValue1, (short)0, (short)RecValue1.length); + + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 34 : Enhanced mode, search backward, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 34; + try + { + patt = new byte[15]; + // 5 readRecord() to set record pointer to record 6 + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + UiccFileView.readRecord((short)0, REC_ACC_MODE_NEXT, (short)0, patt, (short)0, (short)0x0F); + + + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0003; + recordNumber = 0; + pattOffset = 0; + pattLength = 2; + respOffset = 3; + respLength = 2; + patt[0] = (byte)0x02; + patt[1] = (byte)0x01; + patt[2] = (byte)0x00; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)1) + { + comp[3] = (short)6; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)0) + { + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 35 : Enhanced mode, search backward, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 35; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS + (short)0x0801; + recordNumber = 0; + pattOffset = 1; + pattLength = 2; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + comp[0] = (short)5; + comp[1] = (short)4; + comp[2] = (short)3; + comp[3] = (short)2; + comp[4] = (short)1; + if ((nbRecFound == (short)5) && + (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0)) + bRes = true; + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 36 : Enhanced mode, search backward given record, start at offset in record + // ----------------------------------------------------------------- + testCaseNb = 36; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0003; + recordNumber = 5; + pattOffset = 0; + pattLength = 2; + respOffset = 3; + respLength = 2; + patt[0] = (byte)0x02; + patt[1] = (byte)0x01; + patt[2] = (byte)0x00; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)1) + { + comp[3] = (short)6; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)0) + { + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 37 : Enhanced mode, search backward given record, start at value in record + // ----------------------------------------------------------------- + testCaseNb = 37; + try + { + // searchRecord + mode = ENHANCED_SEARCH; + searchIndication = SEARCH_INDICATION_START_BACKWARD_FROM_PREVIOUS_GR + (short)0x0801; + recordNumber = 3; + pattOffset = 1; + pattLength = 2; + respOffset = 0; + respLength = 5; + patt[0] = (byte)0x01; + patt[1] = (byte)0x02; + patt[2] = (byte)0x03; + shortArrayFill(resp, (short)0, (short)resp.length, (short)0); + nbRecFound = UiccFileView.searchRecord(mode, recordNumber, searchIndication, patt, pattOffset, pattLength, resp, respOffset, respLength); + + // Verify result + shortArrayFill(comp, (short)0, (short)comp.length, (short)0); + if (nbRecFound == (short)5) + { + comp[0] = (short)3; + comp[1] = (short)2; + comp[2] = (short)1; + comp[3] = (short)5; + comp[4] = (short)4; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else if (nbRecFound == (short)3) + { + comp[0] = (short)3; + comp[1] = (short)2; + comp[2] = (short)1; + if (shortArrayCompare(resp, (short)0, comp, (short)0, (short)resp.length) == 0) + bRes &= true; + else + bRes = false; + } + else + bRes = false; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + + private void shortArrayFill(short buff[], short buffOffset, short fillLength, short value) + { + for (short i = buffOffset; i < (short)(fillLength + buffOffset); i++) + { + buff[i] = value; + } + } + + private byte shortArrayCompare(short buff1[], short buff1Offset, short buff2[], short buff2Offset, short compLength) + { + byte ret = 0; + + for (byte i = 0; ((i < compLength) && (ret == 0)); i++) + { + byte j = (byte)(i+buff1Offset); + byte k = (byte)(i+buff2Offset); + if (buff1[j] != buff2[k]) + ret = 1; + } + return ret; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/Test_Api_4_Afv_Sear.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/Test_Api_4_Afv_Sear.java new file mode 100644 index 0000000000000000000000000000000000000000..2658011ad4bf941ace8f5006ccd136f229e7f16c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/Test_Api_4_Afv_Sear.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_sear; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Sear extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_sear"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Sear() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" ); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "25" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..180d082709e8af206edf88954de575b580e4d183 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_sear.Api_4_Afv_Sear_1 +uicc.test.access.fileadministration.api_4_afv_sear +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/javacard/api_4_afv_sear.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/javacard/api_4_afv_sear.cap new file mode 100644 index 0000000000000000000000000000000000000000..f6615667d18e87cd0bfec228e64b0791a8ee6ea2 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_sear/javacard/api_4_afv_sear.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/Api_4_Afv_Slctb_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/Api_4_Afv_Slctb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..09f455a270abb84359c476f0591e00a78fbbf1a9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/Api_4_Afv_Slctb_1.java @@ -0,0 +1,182 @@ +//----------------------------------------------------------------------------- +// Api_4_Afv_Slctb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_slctb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.* ; + + +public class Api_4_Afv_Slctb_1 extends TestToolkitApplet{ + + + + byte[] data = new byte[4]; + byte[] resp = new byte[4]; + + short fileOffset; + short respOffset; + short respLength; + + + AID AidADF1; + + private AdminFileView theUiccView; + private AdminFileView theFileView; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Slctb_1(){ + + UICCTestConstants objectConstants = new UICCTestConstants(); + AidADF1 = new AID(objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Api_4_Afv_Slctb_1 thisApplet = new Api_4_Afv_Slctb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event){ + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + + + //test case 1: Selection possiblities, UICC file system + try { + theUiccView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select((byte) (0x01)); //EFTNR + theUiccView.select((byte) (0x02)); //EFTNU + theUiccView.select((byte) (0x05)); //EFCNU + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 2: Selection possiblities, ADF1 + + try { + theFileView = AdminFileViewBuilder.getTheAdminFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + theFileView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select((byte) (0x01)); //EFTNR + theUiccView.select((byte) (0x02)); //EFTNU + theUiccView.select((byte) (0x05)); //EFCNU + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 3: Current EF it self can be selected + + try { + theUiccView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select((byte) (0x01)); //EFTNR + theUiccView.select((byte) (0x01)); //EFTNR + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x03; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 4: FILE_NOT_FOUND + + try { + theUiccView.select((byte) (0x55)); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x04; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 5: File context changed + + fileOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + try { + + data[0] = (byte) 0xFF; + data[1] = (byte) 0xFF; + data[2] = (byte) 0xFF; + theUiccView.select((byte) (0x03)); //EFTARU + theUiccView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + if (Util.arrayCompare(data, (short)0, resp, (short)0, (short)3) == 0) { + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x05; + reportTestOutcome(bTestCaseNb, bRes); + + try { + + data[0] = (byte) 0x55; + data[1] = (byte) 0x55; + data[2] = (byte) 0x55; + theUiccView.select((byte) (0x02)); //EFTNU + theUiccView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + if (Util.arrayCompare(data, (short)0, resp, (short)0, (short)3) == 0) { + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome(bTestCaseNb, bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/Test_Api_4_Afv_Slctb.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/Test_Api_4_Afv_Slctb.java new file mode 100644 index 0000000000000000000000000000000000000000..7ca1f3d14c5321f65393ffb9072e8841ee1f6d51 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/Test_Api_4_Afv_Slctb.java @@ -0,0 +1,88 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_slctb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Slctb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_slctb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Slctb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" ); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Selecction possibilities, UICC file system */ + /** Testcase 2 Selection possiblities, ADF1 */ + /** Testcase 3 Current EF itself can be selected */ + /** Testcase 4 FILE_NOT_FOUND */ + /** Testcase 5 File context changed */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..cccfecec032be2491fbca13e9f1ef741ff1dbd6d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_slctb.Api_4_Afv_Slctb_1 +uicc.test.access.fileadministration.api_4_afv_slctb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/javacard/api_4_afv_slctb.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/javacard/api_4_afv_slctb.cap new file mode 100644 index 0000000000000000000000000000000000000000..1ea6f08c2f1701177dd45a65192d17ad441e90d8 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb/javacard/api_4_afv_slctb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/Api_4_Afv_Slctb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/Api_4_Afv_Slctb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..81d4f144eceee97c31e6a9b6381e2f1510b1e69c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/Api_4_Afv_Slctb_Bss_1.java @@ -0,0 +1,812 @@ +//----------------------------------------------------------------------------- +// Api_4_Afv_Slctb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_slctb_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.* ; + + +public class Api_4_Afv_Slctb_Bss_1 extends TestToolkitApplet{ + + public static byte[] FDescriptor = {(byte) 0x82, (byte) 0xFF, (byte) 0xFF, (byte) 0x21, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; + public static byte[] FId_MF = {(byte) 0x83, (byte) 0x02, (byte) 0x3F, (byte) 0x00}; + public static byte[] FId_DFTelecom = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x10}; + public static byte[] FId_DFTest = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x4A}; + public static byte[] FId_EFTaru = {(byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x03}; + public static byte[] FId_EFLaru = {(byte) 0x83, (byte) 0x02, (byte) 0x6F, (byte) 0x0C}; + public static byte[] DFName = {(byte) 0x84, (byte) 0x10, (byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + public static byte[] lifeCycle = {(byte) 0x8A, (byte) 0x01, (byte) 0x05}; + public static byte[] fileSize = {(byte) 0x80, (byte) 0x02, (byte) 0x01, (byte) 0x04}; + public static byte[] secAttributesLARR1a = {(byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x01}; + public static byte[] secAttributesLARR1b = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01}; + public static byte[] secAttributesLARR1c = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x01}; + public static byte[] secAttributesTARR3a = {(byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x03}; + public static byte[] secAttributesTARR3b = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x00, (byte) 0x03, (byte) 0x01, (byte) 0x03}; + public static byte[] secAttributesTARR3c = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x03}; + + public static byte[] fcp; + public static byte[] normalBuffer = new byte[132]; + public static byte[] nullBuffer = null; + + + byte[] resp = new byte[4]; + byte[] data = new byte[4]; + + short dataOffset; + short dataLength; + short fileOffset; + short respOffset; + short respLength; + short recNumber; + byte mode; + short recOffset; + + AID AidADF1; + + private AdminFileView theUiccView; + private AdminFileView theFileView; + + private short findTLV (byte tag, byte[] buffer, short offset) { + + short index=1; + short len; + + index = (short)(index + offset); + + if (buffer[(byte)index]==(byte)0x81) { + index++; + len = (short) (buffer[(byte)index] + index + (short)1); + }else if (buffer[(byte)index]==(byte)0x82){ + index = (short)(index + (short)2); + len = (short) (Util.getShort(buffer,(byte)index) + index); + } + else{ + len = (short) (buffer[(byte)index] + index + (short)1); + } + + + index++; + + while (index < len) { + + if ( (buffer[(byte)index] & (byte)0x7F) == (tag & (byte)0x7F) ) { + return(index); + } + index = (short) (index + (short) buffer[(byte)(index + (byte)1)] + (short)2); + } + + return(0); + + } + + + + /** + * Constructor of the applet + */ + public Api_4_Afv_Slctb_Bss_1(){ + + UICCTestConstants objectConstants = new UICCTestConstants(); + AidADF1 = new AID(objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Api_4_Afv_Slctb_Bss_1 thisApplet = new Api_4_Afv_Slctb_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event){ + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + EnvelopeHandler envHdlr; + short fcpOffset = 0; + short fcpLength = 0; + short result = 0; + + + short FDOffset = (short)2; //offset of File descriptor TLV in fcp + short FDByteOffset = (short)4; //offset of File descriptor byte in fcp + short FIdOffset = (short)6; //offset of File Identifier TLV in fcp + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TEST CASE 0:Get a FileView object, UICC file system + *----------------------------------------------------------------*/ + theUiccView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + /*------------------------------------------------------------------ + * TEST CASE 1: Select EFTARU in MF (Transparent EF) + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + result = theUiccView.select(UICCTestConstants.FID_EF_TARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x41; + if ((result >= 19) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)4)==0) + &&(Util.arrayCompare(FId_EFTaru, (short)0, fcp, FIdOffset, (short)FId_EFTaru.length)==0)) { + + bRes = true; + } + + fcpOffset=findTLV((byte)0x8A, fcp, (short)0);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare(lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + fcpOffset=findTLV((byte)0x80, fcp, (short)0);//file size + if ((fcpOffset !=0) && (Util.arrayCompare(fileSize, (short)0, fcp, fcpOffset, (short)fileSize.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 2: Select EFTaru in MF (Transparent EF) + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 7; + result = theUiccView.select(UICCTestConstants.FID_EF_TARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x41; + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)4)==0)) { + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome(bTestCaseNb, bRes); + + + + /*------------------------------------------------------------------ + * TEST CASE 3: Select DF Test in MF + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + result = theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result >= 17) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)4)==0) + &&(Util.arrayCompare(FId_DFTest, (short)0, fcp, FIdOffset, (short)FId_DFTest.length)==0)) { + + bRes = true; + } + fcpOffset=findTLV((byte)0x8A, fcp, (short)0);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare(lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x03; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 4: Select EF CARU in DF Test(Cyclic EF) + *----------------------------------------------------------------*/ + bRes = false; + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 11; + result = theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDOffset++; + } + FDescriptor[1] = 0x05; + FDescriptor[2] = 0x46; + FDescriptor[4] = 0x00;// record + FDescriptor[5] = 0x03;// length + FDescriptor[6] = 0x02;// number of records + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)7)==0)) { + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x04; + reportTestOutcome(bTestCaseNb, bRes); + + + + + /*------------------------------------------------------------------ + * TEST CASE 5: Select ADF1 + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 5; + fcpLength = 127; + theFileView = AdminFileViewBuilder.getTheAdminFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + result = theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + + fcp[0]=fcp[1]=fcp[2]=fcp[3]=fcp[4]=0x00; + + if (fcp[(byte)(1 + fcpOffset)] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result >= 27) + &&(fcp[0]==(byte)0x00) && (fcp[1]==(byte)0x00) && (fcp[2]==(byte)0x00) && (fcp[3]==(byte)0x00) && (fcp[4]==(byte)0x00) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, (short)(FDOffset + fcpOffset), (short)4)==0)) { + + bRes = true; + } + fcpOffset=findTLV((byte)0x84, fcp, fcpOffset); //DF Name + if ((fcpOffset !=0) && (Util.arrayCompare(DFName, (short)0, fcp, fcpOffset, (short)DFName.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + fcpOffset = 5; + fcpOffset=findTLV((byte)0x8A, fcp, fcpOffset);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare(lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } + else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x05; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 6: Select MF + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 11; + result = theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[(byte)(FDByteOffset+fcpOffset)]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, (short) (fcpOffset+FDOffset), (short)4)==0) + &&(Util.arrayCompare(FId_MF, (short)0, fcp, (short) (fcpOffset+FIdOffset), (short)FId_MF.length)==0)) { + + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 7: Select DF TELECOM in MF + *----------------------------------------------------------------*/ + bRes = false; + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcp[0] = fcp[1] = (byte)0x05; + fcpOffset = 2; + fcpLength = 13; + result = theUiccView.select(UICCConstants.FID_DF_TELECOM, fcp, fcpOffset, fcpLength); + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[(byte)(FDByteOffset+fcpOffset)]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[1] = 0x02; + FDescriptor[2] = 0x78; + if ((result == fcpLength) + &&(fcp[0]==(byte)0x05) && (fcp[1]==(byte)0x05) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, (short) (fcpOffset+FDOffset), (short)4)==0) + &&(Util.arrayCompare(FId_DFTelecom, (short)0, fcp, (short) (fcpOffset+FIdOffset), (short)FId_DFTelecom.length)==0)) { + + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x07; + reportTestOutcome(bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 8: Select EF LARU in DF TEST (Linear FixedEF) + *----------------------------------------------------------------*/ + bRes = false; + try { + FDOffset = (short)2; + FIdOffset = (short)9; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 14; + theUiccView.select(UICCTestConstants.FID_DF_TEST); + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDOffset++; + FIdOffset++; + } + FDescriptor[1] = 0x05; + FDescriptor[2] = 0x42; + FDescriptor[4] = 0x00;// record + FDescriptor[5] = 0x04;// length + FDescriptor[6] = 0x02;// number of records + if ((result == fcpLength) + &&(Util.arrayCompare(FDescriptor, (short)0, fcp, FDOffset, (short)7)==0) + &&(Util.arrayCompare(FId_EFLaru, (short)0, fcp, (short) FIdOffset, (short)FId_EFLaru.length)==0)) { + bRes = true; + } + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x08; + reportTestOutcome(bTestCaseNb, bRes); + + + + /*------------------------------------------------------------------ + * TEST CASE 9: fcp is null + *----------------------------------------------------------------*/ + try { + fcp = nullBuffer; + fcpOffset = 0; + fcpLength = 15; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (NullPointerException npe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x09; + reportTestOutcome(bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 10: fcpOffset < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = -1; + fcpLength = 15; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0A; + reportTestOutcome(bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 11: fcpLength < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = -1; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0B; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 12: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 115; + fcpLength = 18; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0C; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 13: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = (short) (fcp.length+1); + fcpLength = 0; + result = theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0D; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 14: Selection possiblities + *----------------------------------------------------------------*/ + + + try { + fcpOffset = 0; + + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + + theUiccView.select(UICCTestConstants.FID_EF_UICC, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_CNU, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_SUB_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0E; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 15: EF not selected after MF/DF selection + *----------------------------------------------------------------*/ + + try { + + fileOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCConstants.FID_EF_ICCID, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + + theUiccView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x0F; + reportTestOutcome(bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 16: No selection of non-reachable file + *----------------------------------------------------------------*/ + + try { + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x10; + reportTestOutcome(bTestCaseNb, bRes); + + /*--------------------------------------------------------------------- + * TEST CASE 17: No record is selected afterselecting linear fixed EF + *--------------------------------------------------------------------*/ + + try { + + recNumber = (short) 0; + mode = (byte) UICCConstants.REC_ACC_MODE_CURRENT; + recOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 4; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_LARU, fcp, fcpOffset, fcpLength); + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.RECORD_NOT_FOUND); + } + bTestCaseNb = 0x11; + reportTestOutcome(bTestCaseNb, bRes); + + + /*--------------------------------------------------------------------- + * TEST CASE 18: Record pointer in selected cyclic EF + *--------------------------------------------------------------------*/ + bRes = false; + + recNumber = (short) 0; + recOffset = (short) 0; + dataOffset = (short) 0; + dataLength = (short) 3; + respOffset = (short) 0; + respLength = (short) 3; + + try { + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + + data[0] = 1; + data[1] = 2; + data[2] = 3; + mode = UICCConstants.REC_ACC_MODE_PREVIOUS; + theUiccView.updateRecord(recNumber, mode, recOffset, data, dataOffset, dataLength); + + theUiccView.select(UICCTestConstants.FID_EF_CARU, fcp, fcpOffset, fcpLength); + + mode = UICCConstants.REC_ACC_MODE_PREVIOUS; + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + + if (Util.arrayCompare(data, (short)0, resp, (short)0, (short)3)==0) { + bRes = true; + } + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x12; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 19: EF not selected after ADF/DF selection + *----------------------------------------------------------------*/ + + try { + + fileOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 20; + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_EF_UICC, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + + theFileView.readBinary((short) fileOffset, (byte[]) resp, (short) respOffset, (short) respLength); + + bRes = false; + + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x13; + reportTestOutcome(bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 20: Reselection + *----------------------------------------------------------------*/ + + + try { + + //ADF FileView + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + + //UICC FileView + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TAAA, fcp, fcpOffset, fcpLength); + + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x14; + reportTestOutcome(bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 21: Security attributes + *----------------------------------------------------------------*/ + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //ADF FileView + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_EF_LARR1, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesLARR1a, (short)0, fcp, fcpOffset, (short)secAttributesLARR1a.length)==0) + ||(Util.arrayCompare(secAttributesLARR1b, (short)0, fcp, fcpOffset, (short)secAttributesLARR1b.length)==0) + ||(Util.arrayCompare(secAttributesLARR1c, (short)0, fcp, fcpOffset, (short)secAttributesLARR1c.length)==0)) ){ + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x15; + reportTestOutcome(bTestCaseNb, bRes); + + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //UICC FileView + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_EF_TARR3, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesTARR3a, (short)0, fcp, fcpOffset, (short)secAttributesTARR3a.length)==0) + ||(Util.arrayCompare(secAttributesTARR3b, (short)0, fcp, fcpOffset, (short)secAttributesTARR3b.length)==0) + ||(Util.arrayCompare(secAttributesTARR3c, (short)0, fcp, fcpOffset, (short)secAttributesTARR3c.length)==0)) ){ + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x16; + reportTestOutcome(bTestCaseNb, bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/Test_Api_4_Afv_Slctb_Bss.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/Test_Api_4_Afv_Slctb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..0cb0d21c05f3d029a34fe1d60d9aa3e2ee59b8bc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/Test_Api_4_Afv_Slctb_Bss.java @@ -0,0 +1,112 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_slctb_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Slctb_Bss extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_slctb_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Slctb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Select EFTARU in MF (Transparent EF) */ + /** Testcase 2 Select EFTaru in MF (Transparent EF) */ + /** Testcase 3 Select DF Test in MF */ + /** Testcase 4 Select EF CARU in DF Test(Cyclic EF) */ + /** Testcase 5 Select ADF1 */ + /** Testcase 6 Select MF */ + /** Testcase 7 Select DF TELECOM in MF */ + /** Testcase 8 Select EF LARU in DF TEST (Linear FixedEF) */ + /** Testcase 9 fcp is null */ + /** Testcase 10 fcpOffset < 0 */ + /** Testcase 11 fcpLength < 0 */ + /** Testcase 12 fcpOffset + fcpLength > fcp.length */ + /** Testcase 13 fcpOffset + fcpLength > fcp.length */ + /** Testcase 14 Selection possiblities */ + /** Testcase 15 EF not selected after MF/DF selection */ + /** Testcase 16 No selection of non-reachable file */ + /** Testcase 17 No record is selected afterselecting linear fixed EF */ + /** Testcase 18 Record pointer in selected cyclic EF */ + /** Testcase 19 EF not selected after ADF/DF selection */ + /** Testcase 20 Reselection */ + /** Testcase 21 Security attributes */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "16CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + //Select EF CARU + test.selectFile("3F00"); + test.selectFile("7F4A"); + test.selectFile("6F09"); + test.updateRecord("00", "03", "AAAAAA");//Mode previous + test.updateRecord("00", "03", "555555");//Mode previous + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a2b3357e1d8b983bd9364d260a546ee796bc10d4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_slctb_bss.Api_4_Afv_Slctb_Bss_1 +uicc.test.access.fileadministration.api_4_afv_slctb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/javacard/api_4_afv_slctb_bss.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/javacard/api_4_afv_slctb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..8690bcb81f0d07b567a768092d929caebf72dfbd Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slctb_bss/javacard/api_4_afv_slctb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/Api_4_Afv_Slcts_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/Api_4_Afv_Slcts_1.java new file mode 100644 index 0000000000000000000000000000000000000000..bd0e4cc6ac78bc82d09cbc0bbec9dd97f67c49ef --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/Api_4_Afv_Slcts_1.java @@ -0,0 +1,312 @@ +//----------------------------------------------------------------------------- +// Api_1_Fvw_Slcts_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_slcts; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Api_4_Afv_Slcts_1 extends TestToolkitApplet{ + + + byte[] data = new byte[4]; + byte[] resp = new byte[4]; + + short recNumber; + byte mode; + short recOffset; + short dataOffset; + short dataLength; + short respOffset; + short respLength; + + AID AidADF1; + + private AdminFileView theUiccView; + private AdminFileView theFileView; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Slcts_1(){ + + UICCTestConstants objectConstants = new UICCTestConstants(); + AidADF1 = new AID(objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Api_4_Afv_Slcts_1 thisApplet = new Api_4_Afv_Slcts_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event){ + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + //test case 0: Get a FileView object, UICC file system + theUiccView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + + //test case 1: Selection possiblities + try { + + theUiccView.select(UICCTestConstants.FID_EF_UICC); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_CNU); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_DF_SUB_TEST); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_MF); + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 2: Selection possiblities ADF1 + + try { + + theFileView = AdminFileViewBuilder.getTheAdminFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + + theFileView.select(UICCTestConstants.FID_EF_UICC); + theFileView.select(UICCTestConstants.FID_DF_TEST); + theFileView.select(UICCTestConstants.FID_EF_CNU); + theFileView.select(UICCTestConstants.FID_EF_TAAA); + theFileView.select(UICCTestConstants.FID_DF_SUB_TEST); + theFileView.select(UICCTestConstants.FID_DF_TEST); + theFileView.select(UICCTestConstants.FID_EF_TAAA); + theFileView.select(UICCTestConstants.FID_DF_TEST); + + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 3: No selection of unreachable file + + theUiccView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + try { + theUiccView.select(UICCTestConstants.FID_EF_CNU); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x03; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_DF_TEST); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x04; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_EF_TAA); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x05; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_EF_CNU); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_DF_SUB_TEST); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x07; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCTestConstants.FID_EF_TAA); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x08; + reportTestOutcome(bTestCaseNb, bRes); + try { + theUiccView.select(UICCConstants.FID_DF_TELECOM); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.FILE_NOT_FOUND); + } + bTestCaseNb = 0x09; + reportTestOutcome(bTestCaseNb, bRes); + + //test case 4: Self selection + + try { + + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + theUiccView.select(UICCTestConstants.FID_EF_TAAA); + + theFileView = AdminFileViewBuilder.getTheAdminFileView(AidADF1, JCSystem.CLEAR_ON_RESET); + + theFileView.select(UICCTestConstants.FID_ADF); + theFileView.select(UICCTestConstants.FID_ADF); + bRes = true; + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0A; + reportTestOutcome(bTestCaseNb, bRes); + + + + //test case 5: EF not selected after MF/DF selection + + recNumber = (short) 1; + mode = (byte) UICCConstants.REC_ACC_MODE_ABSOLUTE; + recOffset = (short) 0; + data[0] = (byte) 0; + data[1] = (byte) 0; + data[2] = (byte) 0; + dataOffset = (short) 0; + dataLength = (short) 3; + + try { + theUiccView.select(UICCTestConstants.FID_MF); + bRes = true; + theUiccView.updateRecord(recNumber, mode, recOffset, data, dataOffset, dataLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x0B; + reportTestOutcome(bTestCaseNb, bRes); + + try { + theUiccView.select(UICCTestConstants.FID_DF_TEST); + bRes = true; + theUiccView.updateRecord(recNumber, mode, recOffset, data, dataOffset, dataLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.NO_EF_SELECTED); + } + bTestCaseNb = 0x0C; + reportTestOutcome(bTestCaseNb, bRes); + + + //test case 6: No record is selected after selecting linear fixed EF + + try { + theUiccView.select(UICCTestConstants.FID_MF); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_LARU); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0D; + reportTestOutcome(bTestCaseNb, bRes); + + recNumber = (short) 0; + mode = (byte) UICCConstants.REC_ACC_MODE_CURRENT; + recOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 4; + + try { + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.RECORD_NOT_FOUND); + } + bTestCaseNb = 0x0E; + reportTestOutcome(bTestCaseNb, bRes); + + + try { + theUiccView.select(UICCTestConstants.FID_EF_CARU); + bRes = true; + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0F; + reportTestOutcome(bTestCaseNb, bRes); + + recNumber = (short) 0; + mode = (byte) UICCConstants.REC_ACC_MODE_CURRENT; + recOffset = (short) 0; + respOffset = (short) 0; + respLength = (short) 3; + + try { + theUiccView.readRecord(recNumber, mode, recOffset, resp, respOffset, respLength); + bRes = false; + } catch (UICCException uicce){ + bRes = (uicce.getReason() == UICCException.RECORD_NOT_FOUND); + } + bTestCaseNb = 0x10; + reportTestOutcome(bTestCaseNb, bRes); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/Test_Api_4_Afv_Slcts.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/Test_Api_4_Afv_Slcts.java new file mode 100644 index 0000000000000000000000000000000000000000..79a24cb46aa1114e9fd36d379633b5a876c9c535 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/Test_Api_4_Afv_Slcts.java @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_slcts; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Slcts extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_slcts"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Slcts() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Selecction possibilities */ + /** Testcase 2 Selection possiblities ADF1 */ + /** Testcase 3 No selection of unreachable file */ + /** Testcase 4 Self selection */ + /** Testcase 5 EF not selected after MF/DF selection */ + /** Testcase 6 No record is selected after selecting linear fixed EF */ + /** Testcase 7 Record pointer in selected cyclic EF */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "10CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + //Select EF CARU + test.selectFile("3F00"); + test.selectFile("7F4A"); + test.selectFile("6F09"); + test.updateRecord("00", "03", "AAAAAA");//Mode previous + test.updateRecord("00", "03", "555555");//Mode previous + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a3eafd98000d263803b4a6e2b2c674042a282872 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_slcts.Api_4_Afv_Slcts_1 +uicc.test.access.fileadministration.api_4_afv_slcts +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/javacard/api_4_afv_slcts.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/javacard/api_4_afv_slcts.cap new file mode 100644 index 0000000000000000000000000000000000000000..250ef4e5f3b6a38248af4c834ecee726d649d2f7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_slcts/javacard/api_4_afv_slcts.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/Api_4_Afv_Stat_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/Api_4_Afv_Stat_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f4850b02d5f7d7e1b632e435f6da461ca87d73af --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/Api_4_Afv_Stat_1.java @@ -0,0 +1,468 @@ +//----------------------------------------------------------------------------- +// Api_1_Fvw_Stat_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_stat; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.access.* ; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.* ; + + +public class Api_4_Afv_Stat_1 extends TestToolkitApplet { + + public static byte[] FDescriptor = {(byte) 0x82, (byte) 0x02, (byte) 0xFF, (byte) 0x21}; + public static byte[] FId_MF = {(byte) 0x83, (byte) 0x02, (byte) 0x3F, (byte) 0x00}; + public static byte[] FId_DFTelecom = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x10}; + public static byte[] FId_DFTest = {(byte) 0x83, (byte) 0x02, (byte) 0x7F, (byte) 0x4A}; + public static byte[] DFName = {(byte) 0x84, (byte) 0x10, (byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + public static byte[] lifeCycle = {(byte) 0x8A, (byte) 0x01, (byte) 0x05}; + public static byte[] secAttributesARR2a = {(byte) 0x8B, (byte) 0x03, (byte) 0x6F, (byte) 0x06, (byte) 0x02}; + public static byte[] secAttributesARR2b = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x02}; + public static byte[] secAttributesARR2c = {(byte) 0x8B, (byte) 0x06, (byte) 0x6F, (byte) 0x06, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x02}; + public static byte[] secAttributesARR4a = {(byte) 0x8B, (byte) 0x03, (byte) 0x2F, (byte) 0x06, (byte) 0x04}; + public static byte[] secAttributesARR4b = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x01, (byte) 0x04}; + public static byte[] secAttributesARR4c = {(byte) 0x8B, (byte) 0x06, (byte) 0x2F, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x04}; + + public static byte[] normalBuffer = new byte[127]; + public static byte[] nullBuffer = null; + public static byte[] fcp; + AID AidADF1; + + private AdminFileView theUiccView; + private AdminFileView theFileView; + + /** + * The Constructor register the application for the Event. + */ + public Api_4_Afv_Stat_1 () { + + UICCTestConstants objectConstants = new UICCTestConstants (); + AidADF1 = new AID (objectConstants.AID_ADF1, (short) 0, (byte) objectConstants.AID_ADF1.length); + + } + + private short findTLV (byte tag, byte[] buffer, short offset) { + + short index=1; + short len; + + index = (short)(index + offset); + + if (buffer[(byte)index]==(byte)0x81) { + index++; + len = (short) (buffer[(byte)index] + index + (short)1); + }else if (buffer[(byte)index]==(byte)0x82){ + index = (short)(index + (short)2); + len = (short) (Util.getShort(buffer,(byte)index) + index); + } + else{ + len = (short) (buffer[(byte)index] + index + (short)1); + } + + + index++; + + while (index < len) { + + if ( (buffer[(byte)index] & (byte)0x7F) == (tag & (byte)0x7F) ) { + return(index); + } + index = (short) (index + (short) buffer[(byte)(index + (byte)1)] + (short)2); + } + + return(0); + + } + + + + public static void install (byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance. + Api_4_Afv_Stat_1 thisApplet = new Api_4_Afv_Stat_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register (bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init (); + + thisApplet.obReg.setEvent (EVENT_UNRECOGNIZED_ENVELOPE); + + } + + public void processToolkit (short event) throws ToolkitException { + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + EnvelopeHandler envHdlr; + short fcpOffset = 0; + short fcpLength = 0; + short result = 0; + + + short FDOffset = (short)2; //offset of File descriptor TLV in fcp + short FDByteOffset = (short)4; //offset of File descriptor byte in fcp + short FIdOffset = (short)6; //offset of File Identifier TLV in fcp + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TEST CASE 01: Status of MF + *----------------------------------------------------------------*/ + + theUiccView = AdminFileViewBuilder.getTheUICCAdminFileView (JCSystem.CLEAR_ON_RESET); + + try { + fcp = normalBuffer; + fcpOffset = 3; + fcpLength = 11; + fcp[0]=fcp[1]=fcp[2]= (byte)0xCC; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[(byte)(0x01 + fcpOffset)] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[(byte)(FDByteOffset+fcpOffset)]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + if ((result == fcpLength) + &&(Util.arrayCompare (FDescriptor, (short)0, fcp, (short) (fcpOffset+FDOffset), (short)FDescriptor.length)==0) + &&(Util.arrayCompare (FId_MF, (short)0, fcp, (short) (fcpOffset+FIdOffset), (short)FId_MF.length)==0) + &&(fcp[0]==(byte)0xCC) && (fcp[1]==(byte)0xCC) && (fcp[2]==(byte)0xCC)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x01; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 02: Status after select EF TARU in MF + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + + theUiccView.select (UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select (UICCTestConstants.FID_EF_TARU, fcp, fcpOffset, fcpLength); + + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[FDByteOffset]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + if ((result >= 19) + &&(Util.arrayCompare (FDescriptor, (short)0, fcp, FDOffset, (short)FDescriptor.length)==0) + &&(Util.arrayCompare (FId_DFTest, (short)0, fcp, FIdOffset, (short)FId_DFTest.length)==0)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x02; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Status of DF Telecom + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + theUiccView.select (UICCConstants.FID_DF_TELECOM, fcp, fcpOffset, fcpLength); + + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FIdOffset++; + FDOffset++; + } + if ((result >= 17) + &&(Util.arrayCompare (FId_DFTelecom, (short)0, fcp, FIdOffset, (short)FId_DFTelecom.length)==0)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x03; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Status DF Telecom + *----------------------------------------------------------------*/ + bRes = false; + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 11; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[FDByteOffset]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + if ((result == fcpLength) + &&(Util.arrayCompare (FDescriptor, (short)0, fcp, FDOffset, (short)FDescriptor.length)==0) + &&(Util.arrayCompare (FId_DFTelecom, (short)0, fcp, FIdOffset, (short)FId_DFTelecom.length)==0)) { + + bRes = true; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x04; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Status ADF1 + *----------------------------------------------------------------*/ + bRes = false; + + theFileView = AdminFileViewBuilder.getTheAdminFileView (AidADF1, JCSystem.CLEAR_ON_RESET); + + try { + FDOffset = (short)2; + FDByteOffset = (short)4; + FIdOffset = (short)6; + + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + result = theFileView.status (fcp, fcpOffset, fcpLength); + + if (fcp[1] == (byte)0x81)//if length is coded in 2 bytes, increase the offsets + { + FDByteOffset++; + FIdOffset++; + FDOffset++; + } + fcp[FDByteOffset]|= 0x40; // Set to 1 the bit7 (shareable file) + FDescriptor[2]= 0x78; + //File Descriptor + if ((result >= 27) && (Util.arrayCompare (FDescriptor, (short)0, fcp, FDOffset, (short)FDescriptor.length)==0)) { + + bRes = true; + } + fcpOffset=findTLV ((byte)0x84, fcp, (short)0);//DF Name + if ((fcpOffset !=0) && (Util.arrayCompare (DFName, (short)0, fcp, fcpOffset, (short)DFName.length)==0)) { + + bRes &= true; + } else { + bRes = false; + } + + fcpOffset=findTLV ((byte)0x8A, fcp, (short)0);//life cycle + if ((fcpOffset !=0) && (Util.arrayCompare (lifeCycle, (short)0, fcp, fcpOffset, (short)lifeCycle.length)==0)) { + + bRes &= true; + } else { + bRes = false; + } + + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x05; + reportTestOutcome (bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 06: fcp is null + *----------------------------------------------------------------*/ + try { + fcp = nullBuffer; + fcpOffset = 0; + fcpLength = 34; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (NullPointerException npe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x06; + reportTestOutcome (bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 07: fcpOffset < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = -1; + fcpLength = 34; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x07; + reportTestOutcome (bTestCaseNb, bRes); + /*------------------------------------------------------------------ + * TEST CASE 08: fcpLength < 0 + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = -1; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x08; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = (short)(fcp.length - 1); + fcpLength = 15; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x09; + reportTestOutcome (bTestCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 10: fcpOffset + fcpLength > fcp.length + *----------------------------------------------------------------*/ + try { + fcp = normalBuffer; + fcpOffset = (short)(fcp.length+1); + fcpLength = 0; + result = theUiccView.status (fcp, fcpOffset, fcpLength); + bRes = false; + } catch (ArrayIndexOutOfBoundsException aioobe) { + bRes = true; + } catch (Exception e) { + bRes = false; + } + bTestCaseNb = 0x0A; + reportTestOutcome (bTestCaseNb, bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 11: Security attributes + *----------------------------------------------------------------*/ + + try { + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //ADF FileView + theFileView.select(UICCTestConstants.FID_ADF, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theFileView.select(UICCTestConstants.FID_DF_ARR2, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesARR2a, (short)0, fcp, fcpOffset, (short)secAttributesARR2a.length)==0) + ||(Util.arrayCompare(secAttributesARR2b, (short)0, fcp, fcpOffset, (short)secAttributesARR2b.length)==0) + ||(Util.arrayCompare(secAttributesARR2c, (short)0, fcp, fcpOffset, (short)secAttributesARR2c.length)==0)) ) { + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0B; + reportTestOutcome(bTestCaseNb, bRes); + + try { + + bRes = false; + fcp = normalBuffer; + fcpOffset = 0; + fcpLength = 127; + + //UICC FileView + theUiccView.select(UICCTestConstants.FID_MF, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_TEST, fcp, fcpOffset, fcpLength); + theUiccView.select(UICCTestConstants.FID_DF_ARR4, fcp, fcpOffset, fcpLength); + + fcpOffset=findTLV((byte)0x8B, fcp, fcpOffset); //security attributes + + if ( (fcpOffset !=0) + && ((Util.arrayCompare(secAttributesARR4a, (short)0, fcp, fcpOffset, (short)secAttributesARR4a.length)==0) + ||(Util.arrayCompare(secAttributesARR4b, (short)0, fcp, fcpOffset, (short)secAttributesARR4b.length)==0) + ||(Util.arrayCompare(secAttributesARR4c, (short)0, fcp, fcpOffset, (short)secAttributesARR4c.length)==0)) ) { + + bRes = true; + } + + } catch (Exception e){ + bRes = false; + } + bTestCaseNb = 0x0C; + reportTestOutcome(bTestCaseNb, bRes); + + + + } // end if + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/Test_Api_4_Afv_Stat.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/Test_Api_4_Afv_Stat.java new file mode 100644 index 0000000000000000000000000000000000000000..9d3e05d3b8fd925881d3dfe076bd2e77fb207e3f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/Test_Api_4_Afv_Stat.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_stat; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_4_Afv_Stat extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_afv_stat"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Stat() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 Status of MF */ + /** Testcase 2 Status after select EF TARU in MF */ + /** Testcase 3 Status of DF Telecom */ + /** Testcase 4 Status DF Telecom */ + /** Testcase 5 Status ADF1 */ + /** Testcase 6 fcp is null */ + /** Testcase 7 fcpOffset < 0 */ + /** Testcase 8 fcpLength < 0 */ + /** Testcase 9 fcpOffset + fcpLength > fcp.length */ + /** Testcase 10 fcpOffset + fcpLength > fcp.length */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..fb355995f30cf27f9c32adeefe1b4d954c7dfb6a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_stat.Api_4_Afv_Stat_1 +uicc.test.access.fileadministration.api_4_afv_stat +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/javacard/api_4_afv_stat.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/javacard/api_4_afv_stat.cap new file mode 100644 index 0000000000000000000000000000000000000000..080600ff245061defdff0449c7af8cc3f23df26f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_stat/javacard/api_4_afv_stat.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/Api_4_Afv_Updb_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/Api_4_Afv_Updb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1bfc42015737c1bb0889ef2313d175e4ff17d58a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/Api_4_Afv_Updb_1.java @@ -0,0 +1,389 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Updb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_updb; + +import javacard.framework.*; +import uicc.access.*; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_updb + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_4_Afv_Updb_1 extends TestToolkitApplet implements UICCConstants +{ + private AdminFileView UiccFileView = null; + + final short DATA_BUFFER_LENGTH = (short)0x14; + + byte[] data = new byte[DATA_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[DATA_BUFFER_LENGTH]; + byte[] resp = new byte[DATA_BUFFER_LENGTH]; + + private short respOffset; + private short respLength; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Updb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Updb_1 thisApplet = new Api_4_Afv_Updb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short dataOffset = 0; + short dataLength = 10; + short fileOffset = 0; + + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0); + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*----------------------------------------------------------------------------------- + * TEST CASE 01: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + bRes = false; + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + try { + data[0] = (byte)0x55; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + + /*------------------------------------------------------------------ + * TEST CASE 02: Update transparent file at a given offset + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + try { + + fileOffset = (short)0x03; + dataOffset = (short)0; + dataLength = (short)1; + + // Initialise data buffer + data[0] = (byte)0x55; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + // Read the updated file + respOffset = (short)0; + respLength = (short)1; + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0); + UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + // Initialise the compare buffer and check the readbinary() result + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + compareBuffer[0] = (byte)0x55; + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: fileOffset = 254 + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + fileOffset = (short)0xFE; + dataOffset = 0; + dataLength = 3; + data[0] = (byte)0x55; + data[1] = (byte)0xAA; + data[2] = (byte)0x66; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + // Read the updated file + respOffset = (short)0; + respLength = (short)3; + Util.arrayFillNonAtomic(resp,(short)0,(short)resp.length,(byte)0); + UiccFileView.readBinary(fileOffset, resp, respOffset, respLength); + + // Initialise the compare buffer and check the readbinary() result + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + compareBuffer[0] = (byte)0x55; + compareBuffer[1] = (byte)0xAA; + compareBuffer[2] = (byte)0x66; + if (Util.arrayCompare(resp, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 04: Errorcase, fileOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + fileOffset = (short)-1; + dataOffset = 0; + dataLength = 10; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Errorcase, fileOffset + dataLength > EF length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + fileOffset = (short)259; + dataOffset = 0; + dataLength = 2; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_FILE_BOUNDARIES); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 06: Errorcase, data is null + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + fileOffset = 0; + dataOffset = 0; + dataLength = 10; + UiccFileView.updateBinary(fileOffset, null, dataOffset, dataLength); + bRes = false; + } + catch (NullPointerException npe) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 07: Errorcase, dataOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + fileOffset = 0; + dataOffset = (short)-1; + dataLength = 10; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 08: Errorcase, dataLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + fileOffset = 0; + dataOffset = 0; + dataLength = (short)-1; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: Errorcase, dataOffset + dataLength > data.Length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + fileOffset = 0; + dataOffset = 0x0A; + dataLength = 0x0B; + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Errorcase, EF is not transparent + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + fileOffset = 0; + dataOffset = 0; + dataLength = 1; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Errorcase, Access condition not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TNU); + + fileOffset = 0; + dataOffset = 0; + dataLength = 1; + + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Errorcase, EF is invalidated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_TNR); + UiccFileView.deactivateFile(); + + try { + UiccFileView.updateBinary(fileOffset, data, dataOffset, dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + + reportTestOutcome(testCaseNb,bRes); + + /*---------------------------------------------------------------------------------- + * Reset the file content + *---------------------------------------------------------------------------------*/ + fileOffset = (short)0x00; + dataOffset = (short)0; + + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + // Initialise data buffer + byte[] toto = new byte[0x0104]; + Util.arrayFillNonAtomic(toto,(short)0,(short)toto.length,(byte)0xFF); + // Reset the file content + UiccFileView.updateBinary(fileOffset, toto, dataOffset, (short)toto.length); + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/Test_Api_4_Afv_Updb.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/Test_Api_4_Afv_Updb.java new file mode 100644 index 0000000000000000000000000000000000000000..8be56ad383915e3ac66d6ef5b7988ed4ccc2486a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/Test_Api_4_Afv_Updb.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Fvw_Updb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_updb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_updb + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_4_Afv_Updb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_updb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Updb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" ); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..0c56610a66330713771dfa8bea1a73df779630d2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_updb.Api_4_Afv_Updb_1 +uicc.test.access.fileadministration.api_4_afv_updb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/javacard/api_4_afv_updb.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/javacard/api_4_afv_updb.cap new file mode 100644 index 0000000000000000000000000000000000000000..78ab33018f4029d6f80d5a6b2293361f4801b4f3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updb/javacard/api_4_afv_updb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/Api_4_Afv_Updr_1.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/Api_4_Afv_Updr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..71525eed33a3fbfc12e74875208b2b985a668e4d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/Api_4_Afv_Updr_1.java @@ -0,0 +1,854 @@ +//----------------------------------------------------------------------------- +//Api_1_Fvw_Updr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_updr; + +import javacard.framework.*; +import uicc.access.*; +import uicc.access.fileadministration.AdminFileView; +import uicc.access.fileadministration.AdminFileViewBuilder; +import uicc.test.util.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_updr + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_4_Afv_Updr_1 extends TestToolkitApplet implements UICCConstants +{ + private AdminFileView UiccFileView = null; + + final short DATA_BUFFER_LENGTH = (short)0x14; + + byte[] data = new byte[DATA_BUFFER_LENGTH]; + byte[] compareBuffer = new byte[DATA_BUFFER_LENGTH]; + byte[] respBuffer = new byte[DATA_BUFFER_LENGTH]; + + /** + * Constructor of the applet + */ + public Api_4_Afv_Updr_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_4_Afv_Updr_1 thisApplet = new Api_4_Afv_Updr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + short dataOffset = 0; + short dataLength = 0; + short fileOffset = 0; + short recOffset = 0; + byte recNumber = 0; + short respOffset = 0; + short respLength = 0; + + // Result of tests + boolean bRes = false; + byte testCaseNb = 0; + + // Get the the Uicc FileView and AdminFileView + UiccFileView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*----------------------------------------------------------------------------------- + * TEST CASE 01: Errorcase, No EF selected + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x01; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + recNumber = 1; + dataOffset = 0; + dataLength = 0x0A; + + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.NO_EF_SELECTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb,bRes); + + /*------------------------------------------------------------------ + * TEST CASE 02: Update Absolute linear fixed file + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x02; + bRes = false; + try { + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Test case 1.1: Record pointer not set + recNumber = 2; + recOffset = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)dataLength,(byte)0x11); + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0); + Util.arrayFillNonAtomic(data,(short)0,(short)dataLength,(byte)0x11); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + // Read the updated file in ABSOLUTE Mode + respLength = (short)4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(data, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 03: Update current linear fixed EF + *----------------------------------------------------------------*/ + testCaseNb = (byte)0x03; + bRes = false; + try { + recNumber = 0; + recOffset = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0x00); + + // Set the record pointer to record 1 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + // Call the updateRecord() method in CURRENT mode + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0x22); + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + + // Read the updated file in CURRENT Mode + respLength = (short)4; + // Initialise respBuffer and compareBuffer + Util.arrayFillNonAtomic(respBuffer,(short)0,(short)respBuffer.length,(byte)0x00); + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x22); + + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*---------------------------------------------------------------------------- + * TEST CASE 04: Update next from a linear fixed file, record pointer not set + *----------------------------------------------------------------------------*/ + testCaseNb = (byte)0x04; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Select EF LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x33); + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x33); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 05: Update next from linear fixed EF,record pointer set + *------------------------------------------------------------------*/ + testCaseNb = (byte)0x05; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x44); + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x44); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------------------- + * TEST CASE 06: Update next linear fixed file, no more record + *-------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x06; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + + bRes = false; + } + catch(UICCException e) + { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*---------------------------------------------------------------------------------- + * TEST CASE 07: Update previous from a linear fixed file, record pointer not set + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x07; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Select linear fixed file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x66); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x66); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*---------------------------------------------------------------------------------- + * TEST CASE 08: Update previous from a linear fixed file, record pointer not set + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x08; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x77); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0x77); + + // Call the updateRecord() method + respLength = 4; + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*------------------------------------------------------------------ + * TEST CASE 09: Update previous, no more record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x09; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x04; + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x77); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + } + catch(UICCException e) + { + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 10: Update previous from cylic EF + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0A; + bRes = false; + try { + recNumber = 0; + dataOffset = 0; + dataLength = 0x03; + + // Select cyclic file EF CARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + + // Initialise data buffer + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0x00); + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0xFF); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0x00); + Util.arrayFillNonAtomic(compareBuffer,(short)0,dataLength,(byte)0xFF); + + // Call the updateRecord() method + recOffset = 0; + respLength = 3; + respOffset = 0; + Util.arrayFillNonAtomic(respBuffer,(short)0,(short)respBuffer.length,(byte)0x00); + UiccFileView.readRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,respBuffer,respOffset,respLength); + if (Util.arrayCompare(respBuffer, (short)0, compareBuffer, (short)0, DATA_BUFFER_LENGTH) == 0) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 11: Update linear fixed file in ABSOLUTE mode beyond record + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0B; + bRes = false; + try { + recNumber = (short)-1; + dataOffset = 0; + dataLength = 0x04; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method with recNumber set to -1 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch(Exception e) { + bRes = false; + } + + try { + recNumber = (short)3; + dataOffset = 0; + dataLength = 0x04; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method with recNumber set to 3 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes &= (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch(Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 12: Update linear fixed file in CURRENT mode, record pointer not set + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0C; + bRes = false; + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x04; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.RECORD_NOT_FOUND); + } + catch(Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 13: recOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0D; + bRes = false; + try { + recNumber = (short)1; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)-1; + + // Select cyclic file EF LARU + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + // Call the updateRecord() method with recOffset set to -1 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch(Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 14: recOffset + dataLength > record.length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0E; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)1; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)2; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.OUT_OF_RECORD_BOUNDARIES); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 15: Invalid mode, linear fixed file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x0F; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)0; + // Call the updateRecord() method with mode set to 1 + UiccFileView.updateRecord(recNumber,(byte)1,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x04; + recOffset = (short)0; + // Call the updateRecord() method with mode set to 5 + UiccFileView.updateRecord(recNumber,(byte)5,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= (e.getReason() == UICCException.INVALID_MODE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 16: Invalid mode cyclic file + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x10; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + Util.arrayFillNonAtomic(data,(short)0,(short)data.length,(byte)0); + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode NEXT + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_NEXT,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes = ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode CURRENT, recNumber set to 0 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)2; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode ABSOLUTE, recNumber set to 2 + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + try { + recNumber = (short)0; + dataOffset = 0; + dataLength = 0x03; + recOffset = (short)0; + // Call the updateRecord() method with mode set to 5, recNumber set to 0 + UiccFileView.updateRecord(recNumber,(byte)5,recOffset,data,dataOffset,dataLength); + } + catch (UICCException e) { + bRes &= ((e.getReason() == UICCException.INVALID_MODE) + ||(e.getReason() == UICCException.COMMAND_INCOMPATIBLE)); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 17: data is null + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x11; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = 1; + dataOffset = 0; + dataLength = 4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,null,dataOffset,dataLength); + bRes = false; + } + catch(NullPointerException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 18: dataOffset < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x12; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + + try { + recNumber = 1; + dataOffset = (short)-1; + dataLength = 4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 19: dataLength < 0 + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x13; + bRes = false; + + try { + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)-1; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 20: dataOffset + dataLength > data.length + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x14; + bRes = false; + + try { + recNumber = 1; + dataOffset = (short)18; + dataLength = 4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(ArrayIndexOutOfBoundsException e){ + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 21: EF is neither cylic or linear fixed + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x15; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_DF_TEST); + UiccFileView.select(UICCTestConstants.FID_EF_TARU); + + try { + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_CURRENT,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.COMMAND_INCOMPATIBLE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 22: Access not fulfilled + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x16; + bRes = false; + + // Select cylic file, Update access set to NEV + UiccFileView.select(UICCTestConstants.FID_EF_CNU); + + try { + recNumber = 0; + dataOffset = (short)0; + dataLength = (short)3; + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(UICCException e){ + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + // Select linear fixed file, Update access set to NEV + UiccFileView.select(UICCTestConstants.FID_EF_LNU); + + try { + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)4; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch(UICCException e){ + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + /*----------------------------------------------------------------------------------- + * TEST CASE 23: EF is deactivated + *----------------------------------------------------------------------------------*/ + testCaseNb = (byte)0x17; + bRes = false; + + UiccFileView.select(UICCTestConstants.FID_EF_CNR); + UiccFileView.deactivateFile(); + + try { + recNumber = 0; + dataOffset = (short)0; + dataLength = (short)3; + // Call the updateRecord() method + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + bRes = false; + } + catch (UICCException e) { + bRes = (e.getReason() == UICCException.REF_DATA_INVALIDATED); + } + finally { + UiccFileView.activateFile(); + } + reportTestOutcome(testCaseNb,bRes); + + /*----------------------------------------- + * Restore the file content + *-----------------------------------------*/ + // Restore EF_LARU + UiccFileView.select(UICCTestConstants.FID_EF_LARU); + recNumber = 1; + dataOffset = (short)0; + dataLength = (short)4; + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x55); + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0xAA); + recNumber = 2; + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_ABSOLUTE,recOffset,data,dataOffset,dataLength); + + // Restore EF CARU + UiccFileView.select(UICCTestConstants.FID_EF_CARU); + recNumber = 0; + dataLength = 3; + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + + Util.arrayFillNonAtomic(data,(short)0,dataLength,(byte)0x55); + UiccFileView.updateRecord(recNumber,UICCConstants.REC_ACC_MODE_PREVIOUS,recOffset,data,dataOffset,dataLength); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/Test_Api_4_Afv_Updr.java b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/Test_Api_4_Afv_Updr.java new file mode 100644 index 0000000000000000000000000000000000000000..af1589a4b712c9ff2f3433f6ab55c8cc648f244a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/Test_Api_4_Afv_Updr.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +//Test_Api_1_Fvw_Updr.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.access.fileadministration.api_4_afv_updr; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.access.fileadministration.api_4_afv_updr + * + * @version 0.0.1 - 8 déc. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_4_Afv_Updr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/access/fileadministration/api_4_Afv_updr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 40010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 40010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_4_Afv_Updr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" ); // LV Access Domain DAP field + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + // Trigger Applet envelope unrecognized + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "17CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC"); + + test.reset(); + test.terminalProfileSession("0101"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/applet.opt b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..dc0338d68c440b0e4051a97b670a189ee4fce428 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x01:0x00:0x01 uicc.test.access.fileadministration.api_4_afv_updr.Api_4_Afv_Updr_1 +uicc.test.access.fileadministration.api_4_afv_updr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x40:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/javacard/api_4_afv_updr.cap b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/javacard/api_4_afv_updr.cap new file mode 100644 index 0000000000000000000000000000000000000000..e103dcae7b64078956e59e2d20b9ea9c352171b3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/access/fileadministration/api_4_afv_updr/javacard/api_4_afv_updr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/Cre_Api_Hepo_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/Cre_Api_Hepo_1.java new file mode 100644 index 0000000000000000000000000000000000000000..dcd4217dacd875e8605eaabed1241c142c7e18da --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/Cre_Api_Hepo_1.java @@ -0,0 +1,172 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_hepo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Cat Runtime Environment, Others parts transferred from API, a Handler is JCRE temporary entry point object + * applet 1 + */ +public class Cre_Api_Hepo_1 extends TestToolkitApplet { + + private byte testCaseNb = (byte)0x00; + private static boolean bRes; + + /** Registry entry concerning applet instance */ + private static byte[] displayString = {(byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O'}; + + static Object staticObject; + Object object; + + // Constructor of the applet + public Cre_Api_Hepo_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Api_Hepo_1 thisApplet = new Cre_Api_Hepo_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + /** Test Case 1: EnvelopeHandler with static field */ + testCaseNb = (byte)1; + + bRes = false ; + try { + staticObject = EnvelopeHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 2: EnvelopeHandler with field */ + testCaseNb = (byte)2; + + bRes = false ; + try { + object = EnvelopeHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 3: EnvelopeResponseHandler with static field */ + testCaseNb = (byte)3; + + bRes = false ; + try { + staticObject = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 4: EnvelopeResponseHandler with field */ + testCaseNb = (byte)4; + + bRes = false ; + try { + object = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 5: ProactiveHandler with static field */ + testCaseNb = (byte)5; + + bRes = false ; + try { + staticObject = ProactiveHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 6: ProactiveHandler with field */ + testCaseNb = (byte) 6; + + bRes = false ; + try { + object = ProactiveHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 7: ProactiveResponseHandler with static field */ + testCaseNb = (byte)7; + // send proactive command to have the ProactiveResponseHandler available + ProactiveHandlerSystem.getTheHandler().initDisplayText((byte)0x80, (byte)0x04, displayString, (short)0, (short)displayString.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + + bRes = false ; + try { + staticObject = ProactiveResponseHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 8: ProactiveResponseHandler with field */ + testCaseNb = (byte)8; + bRes = false ; + try { + object = ProactiveResponseHandlerSystem.getTheHandler(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/Test_Cre_Api_Hepo.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/Test_Cre_Api_Hepo.java new file mode 100644 index 0000000000000000000000000000000000000000..80cfadaceb0c0be8187b82287058b17a0cae84bc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/Test_Cre_Api_Hepo.java @@ -0,0 +1,80 @@ +/** + * ETSI TS 102 268: UICC API testing + * Cat Runtime Environment part 5 + * Test source for Other parts transferred to framework from API + * A handler is a temporary JCRE Entry Point object + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_hepo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Cre_Api_Hepo extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_api_hepo"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Api_Hepo() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("01010000 0102"); + + // test case 1 to 8: trigger applet1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9113"); + + // fetch display text proactive command + response = test.fetch("13"); + result = result & response.checkData("D0118103 01218082 0281028D 06044845" + + "4C4C4F"); + response = test.terminalResponse("81030121 80020282 81030100"); + result = result & response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = result & response.checkData("10" + APPLET_AID_1 + "08CCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9a75dac706e5f2057b003f3858836e2f15997910 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_api_hepo.Cre_Api_Hepo_1 +uicc.test.catre.cre_api_hepo +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/javacard/cre_api_hepo.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/javacard/cre_api_hepo.cap new file mode 100644 index 0000000000000000000000000000000000000000..494fe81b93f88f68a87f1eae69f474aeff2347ae Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_hepo/javacard/cre_api_hepo.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/Cre_Api_Tmid_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/Cre_Api_Tmid_1.java new file mode 100644 index 0000000000000000000000000000000000000000..36b5ad2c0544f7a59f1e42568708d931d43c9d95 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/Cre_Api_Tmid_1.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// Cre_Api_Tmid_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_tmid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * Cat Runtime Environment, Other parts transferred from API, Timer Identifier test + * applet 1 + */ +public class Cre_Api_Tmid_1 extends TestToolkitApplet { + + static byte instanceNumber = (byte)0x00; + static byte firstInstanceTimerId = (byte)0x00; + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'1'}; + + // Number of tests + byte testCaseNb = (byte)0x00; + + /** + * Constructor of the applet + */ + public Cre_Api_Tmid_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Api_Tmid_1 thisApplet = new Cre_Api_Tmid_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short)0, (short)MenuInit.length, (byte)0, + false, (byte)0, (short)0); + + // Allocate a timer + byte timerId = thisApplet.obReg.allocateTimer(); + + if (instanceNumber == 0) { + firstInstanceTimerId = timerId; + } + instanceNumber++; + } + + + /** + * method called by the CAT RE + */ + public void processToolkit(short event) { + // Result of tests + boolean bRes = false ; + + // -------------------------------------------- + // Test Case 1 : Verify the impossibility of releasing another applet timer + testCaseNb = (byte)1; + + bRes = false; + + + try { + obReg.releaseTimer(firstInstanceTimerId); + } + catch (ToolkitException e) { + // Check the exception is the good one and the timer has been allocated + if ((e.getReason() == ToolkitException.INVALID_TIMER_ID) + && (firstInstanceTimerId != 0)) + bRes = true; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/Test_Cre_Api_Tmid.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/Test_Cre_Api_Tmid.java new file mode 100644 index 0000000000000000000000000000000000000000..63b4ee1da859f243548bed0d846dd14ff6c30fdf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/Test_Cre_Api_Tmid.java @@ -0,0 +1,90 @@ +/** + * ETSI TS 102 268: UICC API testing + * Cat Runtime Environment part 5 + * Test source for Other parts transferred to framework from API + * Timer Id between Applets + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_tmid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Cre_Api_Tmid extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_api_tmid"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Api_Tmid() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package + test.loadPackage(CAP_FILE_PATH); + // install instance 1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "02" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // install instance 2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "02" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0202" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010020"); + + + // test case 1: trigger second instance + response = test.envelopeMenuSelection("900102", ""); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_2); + result = result & response.checkData("10" + APPLET_AID_2 + "01CC"); + + // delete applets and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d388044451d762c78bbec5b3dbcc9b4259c050bc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_api_tmid.Cre_Api_Tmid_1 +uicc.test.catre.cre_api_tmid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/javacard/cre_api_tmid.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/javacard/cre_api_tmid.cap new file mode 100644 index 0000000000000000000000000000000000000000..ada13792e8f1c7a2d8ca6326340b63e22830af50 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tmid/javacard/cre_api_tmid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Cre_Api_Tran_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Cre_Api_Tran_1.java new file mode 100644 index 0000000000000000000000000000000000000000..dbe0ff4db76eef63e729bd508c2afb5919b5d7dd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Cre_Api_Tran_1.java @@ -0,0 +1,100 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_tran; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * Cat Runtime Environment, Others parts transferred from API, Transaction test + * applet 1 + */ + +public class Cre_Api_Tran_1 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + /** Registry entry concerning applet instance */ + private static byte[] displayString = {(byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O', (byte)'1'}; + static byte[] testArray = {(byte)0xFF}; + + // Constructor of the applet + public Cre_Api_Tran_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // Create a new applet instance + Cre_Api_Tran_1 thisApplet = new Cre_Api_Tran_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + switch (testCaseNb) { + case 0x00: + /** Test Case 1: Verify a pending transaction is aborted when a proactive command is sent */ + testCaseNb = (byte)1; + + bRes = false; + testArray[0] = (byte)0x05; + try { + JCSystem.beginTransaction(); + testArray[0] = (byte)0x02; + // send a proactive command to have the ProactiveResponseHandler available + ProactiveHandlerSystem.getTheHandler().initDisplayText((byte)0x80, (byte)0x04, displayString, (short)0, (short)displayString.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + + if ((testArray[0] == (byte)5) && (JCSystem.getTransactionDepth() == 0)) { + bRes = true; + } + } + catch (Exception e) { + } + + reportTestOutcome(testCaseNb, bRes); + + break; + + case 0x01: + /** Test Case 2: Verify a pending transaction is aborted on the termination of a toolkit applet */ + testCaseNb = (byte)2; + + testArray[0] = (byte)0x05; + try { + bRes = true; + reportTestOutcome(testCaseNb, bRes); + bRes = false; + JCSystem.beginTransaction(); + testArray[0] = (byte)0x02; + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + + break; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Cre_Api_Tran_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Cre_Api_Tran_2.java new file mode 100644 index 0000000000000000000000000000000000000000..b84523bc52a06ddcae4e977c4bae2907cf10ae65 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Cre_Api_Tran_2.java @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_tran; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Cat Runtime Environment, Others parts transferred from API, Transaction test + * applet 2 + */ + +public class Cre_Api_Tran_2 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'1'}; + private static byte[] displayString = {(byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O', (byte)'2'}; + + // Constructor of the applet + public Cre_Api_Tran_2() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install (byte bArray[], short bOffset, byte bLength){ + + // Create a new applet instance + Cre_Api_Tran_2 thisApplet = new Cre_Api_Tran_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, + (short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + /** Test Case 2: Verify a pending transaction is aborted on the termination of a toolkit applet */ + testCaseNb = (byte)1; + + bRes = false; + try { + // send a proactive command to have the ProactiveResponseHandler available + ProactiveHandlerSystem.getTheHandler().initDisplayText((byte)0x80, (byte)0x04, displayString, (short)0, (short)displayString.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + + // applet2 is resumed + if ((Cre_Api_Tran_1.testArray[0] == (byte)5) && (JCSystem.getTransactionDepth() == 0)) { + bRes = true; + } + } + catch (Exception e) { + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Test_Cre_Api_Tran.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Test_Cre_Api_Tran.java new file mode 100644 index 0000000000000000000000000000000000000000..fb90144903ae2b0631d8080cdc8e69e62dc99f98 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/Test_Cre_Api_Tran.java @@ -0,0 +1,111 @@ +/** + * ETSI TS 102 268: UICC API testing + * Cat Runtime Environment part 5 + * Test source for Other parts transferred to framework from API + * Transaction + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_api_tran; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Cre_Api_Tran extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_api_tran"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Api_Tran() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("098101"); + + // install package + test.loadPackage(CAP_FILE_PATH); + // install applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test case 1: trigger applet1 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07044845" + + "4C4C4F31"); + response = test.terminalResponse("81030121 80020282 81030100"); + result &= response.checkSw("9000"); + + // install applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("098101"); + + // test case 2: trigger applet2 + response = test.envelopeMenuSelection("900101", ""); + result &= response.checkSw("9114"); + + // trigger applet1 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9114"); + + // resume applet2 + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07044845" + + "4C4C4F32"); + response = test.terminalResponse("81030121 80020282 81030100"); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "02CCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01CC"); + + // delete applets and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..471b7c4b84dca3519a874b3256dd4daf72fad812 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_api_tran.Cre_Api_Tran_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_api_tran.Cre_Api_Tran_1 +uicc.test.catre.cre_api_tran +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/javacard/cre_api_tran.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/javacard/cre_api_tran.cap new file mode 100644 index 0000000000000000000000000000000000000000..966cba62568cfbe48bbb0ea09fe7422224a14f03 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_api_tran/javacard/cre_api_tran.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/Cre_Apt_Eade_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/Cre_Apt_Eade_1.java new file mode 100644 index 0000000000000000000000000000000000000000..215546ab0f8a4519ee27cad3066d312fcb3a8d81 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/Cre_Apt_Eade_1.java @@ -0,0 +1,200 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Eade_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_eade; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_APPLICATION_DESELECT + * + * + * + * + * + */ + + public class Cre_Apt_Eade_1 extends TestToolkitApplet{ + + private static boolean bRes; + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + //private static byte[] ADF1AID ={(byte)0xA0,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x09,(byte)0x00 ,(byte)0x05 ,(byte)0xFF ,(byte)0xFF ,(byte)0xFF ,(byte)0xFF ,(byte)0x89 ,(byte)0xE0 ,(byte)0x00 ,(byte)0x00 ,(byte)0x02}; + //private static byte[] ADF2AID ={(byte)0xA0,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x09,(byte)0x00 ,(byte)0x05 ,(byte)0xFF ,(byte)0xFF ,(byte)0xFF ,(byte)0xFF ,(byte)0x89 ,(byte)0xD0 ,(byte)0x00 ,(byte)0x00 ,(byte)0x02}; + + + + + //Constructor of the applet + public Cre_Apt_Eade_1(){ + + } + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + //Create a new applet instace + Cre_Apt_Eade_1 thisApplet = new Cre_Apt_Eade_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_APPLICATION_DESELECT + thisApplet.obReg.setEvent(EVENT_APPLICATION_DESELECT); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + try{bRes=thisApplet.obReg.isEventSet(EVENT_APPLICATION_DESELECT);} + catch(Exception e){bRes=false;} + } + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + UICCTestConstants UICCTestConstants_i= new UICCTestConstants(); + EnvelopeHandler envHndlr = EnvelopeHandlerSystem.getTheHandler(); + //event EVENT_APPLICATION_DESELECT + if(event==EVENT_APPLICATION_DESELECT){ + //TEST CASE 1: 1 - METHOD isEventSet() RETURNS TRUE + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:3 - THE ENVELOPE HANDLER CONTAINS THE AID OF ADF1 + testCaseNb=(byte)0x02; + + if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF1, (short)0)==0){ + bRes=true; + } + else {bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + + //TEST CASE 1:4 - APPLET IS TRIGGERED. + //THE ENVELOPE HANDLER CONTAINS THE AID OF ADF2 + case (byte)0x02: + testCaseNb=(byte)0x03; + if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF2, (short)0)==0){ + bRes=true; + } + else {bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: 1 - METHOD clearEvent() IS CALLED + testCaseNb=(byte)0x04; + try{ + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x06; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x04; + break; + + case (byte)0x04: + if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF1, (short)0)==0){ + testCaseNb=(byte)0x05; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + } + else if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF2, (short)0)==0){ + testCaseNb=(byte)0x06; + bRes=false; + testCaseNb=(byte)0x04; + + } + else{ + reportTestOutcome((byte)0x05,false); + reportTestOutcome((byte)0x06,false); + testCaseNb=(byte)0x05; + } + break; + + case (byte)0x05: + if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF2, (short)0)==0){ + testCaseNb=(byte)0x06; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + } + else{ + reportTestOutcome((byte)0x06,false); + + } + testCaseNb=(byte)0x04; + break; + + case (byte)0x08: + testCaseNb=(byte)0x09; + + //TEST CASE 2:6 - THE ENVELOPE HANDLER CONTAINS THE AID OF ADF1 + if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF1, (short)0)==0){ + bRes=true; + } + else {bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + + //TEST CASE 2:7 - APPLET IS TRIGGERED THE ENVELOPE HANDLER CONTAINS THE AID OF ADF2 + case (byte)0x09: + testCaseNb=(byte)0x0A; + if(envHndlr.findAndCompareValue((byte)0x2F,UICCTestConstants_i.AID_ADF2, (short)0)==0){ + bRes=true; + } + else {bRes=false;} + reportTestOutcome(testCaseNb,bRes); + + }//end of switch + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + switch(testCaseNb){ + //TEST CASE 2:4 - APPLET IS TRIGGERED + case (byte)0x04: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x08; + try{ + obReg.setEvent(EVENT_APPLICATION_DESELECT); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + + //TEST CASE 2:4 - APPLET IS TRIGGERED. THIS CASE ONLY IF APPLET IS TRIGGERED WRONGLY + case (byte)0x05: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x08; + try{ + obReg.setEvent(EVENT_APPLICATION_DESELECT); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/Test_Cre_Apt_Eade.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/Test_Cre_Apt_Eade.java new file mode 100644 index 0000000000000000000000000000000000000000..3ab8d0ac37211d0cba2c5b9bbe3ed30d7b38fab5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/Test_Cre_Apt_Eade.java @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_APPLICATION_DESELECT +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_eade; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Eade extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_eade"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String ADF1 = "A0000000 090005FF FFFFFF89 E0000002"; + static final String ADF2 = "A0000000 090005FF FFFFFF89 D0000002"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Eade() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + test.selectForActivation(ADF1); + //***TEST CASE 1: 2-APPLET IS TRIGGERED HANDLER CONTAINS THE AID OF ADF1 + test.selectForActivation(ADF2); + //***TEST CASE 1: 3-APPLET IS TRIGGERED HANDLER CONTAINS THE AID OF ADF2 + test.selectForTermination(ADF2); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.selectForActivation(ADF1); + //***TEST CASE 2: 2-APPLET IS NOT TRIGGERED + test.selectForActivation(ADF2); + //***TEST CASE 2: 3-APPLET IS NOT TRIGGERED + test.selectForTermination(ADF2); + //***TEST CASE 2: 4-APPLET IS TRIGGERED + test.envelopeMenuSelection("100101", "");//Help Request not available + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.selectForActivation(ADF1); + //***TEST CASE 2: 6-APPLET IS TRIGGERED HANDLER CONTAINS THE AID OF ADF1 + test.selectForActivation(ADF2); + //***TEST CASE 2: 7-APPLET IS TRIGGERED HANDLER CONTAINS THE AID OF ADF2 + test.selectForTermination(ADF2); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"0ACCCCCC CCCCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..8948b944940616d1d9f8c7ff84d80e79a5949a79 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_eade.Cre_Apt_Eade_1 +uicc.test.catre.cre_apt_eade +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/javacard/cre_apt_eade.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/javacard/cre_apt_eade.cap new file mode 100644 index 0000000000000000000000000000000000000000..6cfd960125cfa0a2d2e6698702a240914fbfe30e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eade/javacard/cre_apt_eade.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Cre_Apt_Eccn_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Cre_Apt_Eccn_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f04cb877f7bcf498b07ad4b5d123cb2159409f3e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Cre_Apt_Eccn_1.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Eccn_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_eccn; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: CAT Runtime Environment Applet Triggering EVENT_CALL_CONTROL_BY_NAA + * + * + * + * + * + */ + +public class Cre_Apt_Eccn_1 extends TestToolkitApplet{ + private byte testCaseNb = (byte) 0x00; + private boolean bRes=false; + + //Constructor of the applet + + public Cre_Apt_Eccn_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Eccn_1 thisApplet = new Cre_Apt_Eccn_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + switch(testCaseNb){ + //TestCase 1: The applet must be triggered + case (byte)0x00: + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + + case (byte)0x01: + //TestCase 2: clearEvent method is called and applet is unregistered + testCaseNb=(byte)0x02; + try{ + obReg.clearEvent(EVENT_CALL_CONTROL_BY_NAA); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte) 0x02: + //TestCase 3: Applet has been unregistered and must not be triggered + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + } + + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Cre_Apt_Eccn_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Cre_Apt_Eccn_2.java new file mode 100644 index 0000000000000000000000000000000000000000..e037007904db5b7c03d4327d614b98d43c26f17b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Cre_Apt_Eccn_2.java @@ -0,0 +1,100 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Eccn_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_eccn; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_CALL_CONTROL_BY_NAA + * + * + * + * + * + */ + +public class Cre_Apt_Eccn_2 extends TestToolkitApplet{ + private byte testCaseNb = (byte) 0x00; + private byte[] TEXT ={(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)' ',(byte)'1'}; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'2'}; + + private boolean bRes; + private byte nbCases =(byte)0x00; + + //Constructor of the applet + + public Cre_Apt_Eccn_2(){ + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Eccn_2 thisApplet = new Cre_Apt_Eccn_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + //Prepare result table for test that the applet is no triggered when + //is deregistered to the event + thisApplet.reportTestOutcome((byte) 0x01,true); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + bRes=false; + if(event==EVENT_MENU_SELECTION ){ + //TestCase 1:displayText command is sent and Applet is registered to + //EVENT_CALL_CONTROL_BY_NAA + testCaseNb=(byte)0x02; + try{ + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.initDisplayText((byte)0x80,(byte)0x04,TEXT,(short)0x00,(short)TEXT.length); + prHdlr.send(); + obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + nbCases=(byte)0x01; + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + } + + if(event==EVENT_CALL_CONTROL_BY_NAA){ + //TestCase 2:Applet must be triggered + switch(nbCases){ + case (byte)0x00: + testCaseNb=(byte)0x01; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x01: + testCaseNb=0x03; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Test_Cre_Apt_Eccn.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Test_Cre_Apt_Eccn.java new file mode 100644 index 0000000000000000000000000000000000000000..62a3d38cf83fb2e647af267f1b31ab49ae77ce58 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/Test_Cre_Apt_Eccn.java @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: CAT Runtime Environment Applet Triggering +// EVENT_CALL_CONTROL_BY_NAA +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_eccn; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Eccn extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_eccn"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Eccn() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A"+ // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + test.terminalProfileSession("09030100 01"); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED*** + test.envelopeCallControlByNAA(); + //***TEST CASE 2: 1-APPLET 2 IS TRIGGERED*** + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result = response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045465" + + "78742031"); + //***TEST CASE 2: 3-APPLET 1 IS TRIGGERED*** + test.envelopeCallControlByNAA(); + //***TERMINAL RESPONSE TO THE DISPLAY TEXT*** + response = test.terminalResponse("81030121 80820282 81030100"); + result &= response.checkSw("9000"); + //***TEST CASE 3: APPLET 2 IS TRIGGERED, APPLET1 IS NOT TRIGGERED*** + test.envelopeCallControlByNAA(); + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"03CCCCCC"); + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..201c570789b14ba62a1c20f68fbfa912078f102e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_eccn.Cre_Apt_Eccn_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_eccn.Cre_Apt_Eccn_1 +uicc.test.catre.cre_apt_eccn +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/javacard/cre_apt_eccn.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/javacard/cre_apt_eccn.cap new file mode 100644 index 0000000000000000000000000000000000000000..c6c3d16f2a1dd275973a8cde61b006c5c5f62be3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eccn/javacard/cre_apt_eccn.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/Cre_Apt_Edat_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/Cre_Apt_Edat_1.java new file mode 100644 index 0000000000000000000000000000000000000000..c400006e37b387d5cfdf66930c437a4572169e03 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/Cre_Apt_Edat_1.java @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edat_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edat; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + * + * + * + * + * + */ + + public class Cre_Apt_Edat_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + //private static ToolkitRegistry obReg; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + + //Constructor of the applet + + public Cre_Apt_Edat_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edat_1 thisApplet = new Cre_Apt_Edat_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + // obReg = ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + if(event==EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5:THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + obReg.setEvent(EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/Test_Cre_Apt_Edat.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/Test_Cre_Apt_Edat.java new file mode 100644 index 0000000000000000000000000000000000000000..4019a7f85ec8391cdc44abb245ff6dc23cde2b68 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/Test_Cre_Apt_Edat.java @@ -0,0 +1,84 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edat; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edat extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edat"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edat() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 0110"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE*** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadAccessTechnologyChange(); + test.fetch("0D"); + test.terminalResponse("81030105 00820282 81830100"); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadAccessTechnologyChange(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE*** + test.envelopeMenuSelection("100101", "");//Help Request not available + test.fetch("0E"); + test.terminalResponse("81030105 00820282 81830100"); + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadAccessTechnologyChange(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..037f3bd80717df8b1bd28fa1dd68a85842502735 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edat.Cre_Apt_Edat_1 +uicc.test.catre.cre_apt_edat +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/javacard/cre_apt_edat.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/javacard/cre_apt_edat.cap new file mode 100644 index 0000000000000000000000000000000000000000..e4d9a62c6467c48cc6e73f367ae95b4b57d95812 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edat/javacard/cre_apt_edat.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/Cre_Apt_Edbs_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/Cre_Apt_Edbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..8692b49746f291cb1cc0a65cd712f034c0e25cfd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/Cre_Apt_Edbs_1.java @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edbs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edbs; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DONWLOAD_BROWSING_STATUS + * + * + * + * + * + */ + + public class Cre_Apt_Edbs_1 extends TestToolkitApplet{ + + private static boolean bRes; + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'1'}; + + //Constructor of the applet + public Cre_Apt_Edbs_1(){ + + } + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + //Create a new applet instace + Cre_Apt_Edbs_1 thisApplet = new Cre_Apt_Edbs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_EVENT_BROWSING_STATUS + thisApplet.obReg.setEvent(EVENT_EVENT_BROWSING_STATUS); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + try{bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_BROWSING_STATUS);} + catch(Exception e){bRes=false;} + } + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + EnvelopeHandler envHndlr = EnvelopeHandlerSystem.getTheHandler(); + //event EVENT_EVENT_BROWSING_STATUS + if(event==EVENT_EVENT_BROWSING_STATUS){ + //TEST CASE 1: 1 - METHOD isEventSet() RETURNS TRUE + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:2 - Applet is triggered + testCaseNb=(byte)0x02; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + + //TEST CASE 2: METHOD clearEvent() IS CALLED + testCaseNb=(byte)0x03; + try{ + obReg.clearEvent(EVENT_EVENT_BROWSING_STATUS); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: 1 - APPLET IS NOT TRIGGERED + testCaseNb=(byte)0x04; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + testCaseNb=(byte)0x04; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2: 3 - APPLET IS TRIGGERED + case (byte)0x06: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + }//end of switch + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + switch(testCaseNb){ + //TEST CASE 2:2 - APPLET IS TRIGGERED + case (byte)0x04: + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //setEvent() doesn't throws any exception + testCaseNb=(byte)0x06; + try{ + obReg.setEvent(EVENT_EVENT_BROWSING_STATUS); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/Test_Cre_Apt_Edbs.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/Test_Cre_Apt_Edbs.java new file mode 100644 index 0000000000000000000000000000000000000000..cf803e8f64936e8187d5d3b4964fa6bb7346c92c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/Test_Cre_Apt_Edbs.java @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DONWLOAD_BROWSING_STATUS +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edbs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edbs extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edbs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edbs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("01010000 01010000 000000FF 5F"); + //***TEST CASE 1: 2-APPLET IS TRIGGERED + test.envelopeEventDownloadBrowsingStatus(); + //***TEST CASE 2: 1-APPLET IS NOT TRIGGERED + test.envelopeEventDownloadBrowsingStatus(); + //***TEST CASE 2: 2-APPLET IS TRIGGERED + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 3-APPLET IS TRIGGERED + test.envelopeEventDownloadBrowsingStatus(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..982fc786da1b36658807f998c882e97ea5e2de73 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edbs.Cre_Apt_Edbs_1 +uicc.test.catre.cre_apt_edbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/javacard/cre_apt_edbs.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/javacard/cre_apt_edbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..4b1e1336c95d225b926b8fc19f8a222ad4b6c9b2 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbs/javacard/cre_apt_edbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/Cre_Apt_Edbt_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/Cre_Apt_Edbt_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f21a186b0a1baf6682447948e6e262fa985431d2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/Cre_Apt_Edbt_1.java @@ -0,0 +1,122 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edbt_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edbt; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering + * EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + * + * + * + * + * + */ + +public class Cre_Apt_Edbt_1 extends TestToolkitApplet{ + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + + //Constructor of the applet + + public Cre_Apt_Edbt_1(){ + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edbt_1 thisApplet = new Cre_Apt_Edbt_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD BROWSER TERMINATION + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + //register to the EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + if(event==EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION){ + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to the event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + // Test Case 3 : THE APPLET MUST NOT BE TRIGGERED + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to the event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + obReg.setEvent(EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/Test_Cre_Apt_Edbt.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/Test_Cre_Apt_Edbt.java new file mode 100644 index 0000000000000000000000000000000000000000..ad9bde177b38786d284481d6facdd86a1c6e9e30 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/Test_Cre_Apt_Edbt.java @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering Event +// EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edbt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edbt extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edbt"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edbt() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 0002"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadBrowserTermination(); + test.terminalProfileSession("09010000 0102"); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadBrowserTermination(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION *** + test.envelopeMenuSelection("100101", "");//Help Request not available + test.terminalProfileSession("09010000 0102"); + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadBrowserTermination(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a5445d6e9a10b6ba8591d6770685ed67e9c83427 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edbt.Cre_Apt_Edbt_1 +uicc.test.catre.cre_apt_edbt +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/javacard/cre_apt_edbt.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/javacard/cre_apt_edbt.cap new file mode 100644 index 0000000000000000000000000000000000000000..8f7fe9b35707d3bf94d0ca8f20bf74cdbfce6b30 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edbt/javacard/cre_apt_edbt.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/Cre_Apt_Edcc_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/Cre_Apt_Edcc_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a46fbea0c56d112208aa8ee28ecdda18efa9e91e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/Cre_Apt_Edcc_1.java @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edcc_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edcc; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + * + * + * + * + * + */ + +public class Cre_Apt_Edcc_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + //private static ToolkitRegistry obReg; + + //Constructor of the applet + + public Cre_Apt_Edcc_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edcc_1 thisApplet = new Cre_Apt_Edcc_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //REGISTER TO EVENT DOWNLOAD CALL CONNECTED + //obReg = ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_CALL_CONNECTED); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_CALL_CONNECTED); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + if(event==EVENT_EVENT_DOWNLOAD_CALL_CONNECTED){ + + switch(testCaseNb){ + //TEST CASE 2:UNREGISTER TO THE EVENT + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x02; + try{ + //deregister to the EVENT_EVENT_DOWNLOAD_CALL_CONNECTED event + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_CALL_CONNECTED); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE:4 REGISTER TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to the event EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + obReg.setEvent(EVENT_EVENT_DOWNLOAD_CALL_CONNECTED); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/Test_Cre_Apt_Edcc.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/Test_Cre_Apt_Edcc.java new file mode 100644 index 0000000000000000000000000000000000000000..846a3a4453d21df0cd3dc358cb788d491a7a3aa2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/Test_Cre_Apt_Edcc.java @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_CALL_CONNECTED +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edcc; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edcc extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edcc"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edcc() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 05"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_CALL_CONNECTED*** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadCallConnected(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadCallConnected(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadCallConnected(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4927aa8e3840201b65736d6c38136645420d1d4f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edcc.Cre_Apt_Edcc_1 +uicc.test.catre.cre_apt_edcc +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/javacard/cre_apt_edcc.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/javacard/cre_apt_edcc.cap new file mode 100644 index 0000000000000000000000000000000000000000..85eb3d96f20821ce1613453d31a3a6d0be46a4a7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcc/javacard/cre_apt_edcc.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/Cre_Apt_Edcd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/Cre_Apt_Edcd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a5aeb262f41f2a0cf949e5ca06bcd123836e3265 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/Cre_Apt_Edcd_1.java @@ -0,0 +1,120 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edcd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edcd; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + * + * + * + * + * + */ + +public class Cre_Apt_Edcd_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + //private static ToolkitRegistry obReg; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + //Constructor of the applet + + public Cre_Apt_Edcd_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edcd_1 thisApplet = new Cre_Apt_Edcd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD CALL DISCONNECTED + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + if(event==EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED){ + + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5:THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + obReg.setEvent(EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/Test_Cre_Apt_Edcd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/Test_Cre_Apt_Edcd.java new file mode 100644 index 0000000000000000000000000000000000000000..f3511cb95e02c4fb813f0dca832f7326019767d7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/Test_Cre_Apt_Edcd.java @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edcd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edcd extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edcd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edcd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 09"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED*** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadCallDisconnected(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadCallDisconnected(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadCallDisconnected(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..66bd17e568c9a107a7331ff1b10523e6a85e0433 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edcd.Cre_Apt_Edcd_1 +uicc.test.catre.cre_apt_edcd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/javacard/cre_apt_edcd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/javacard/cre_apt_edcd.cap new file mode 100644 index 0000000000000000000000000000000000000000..34c406393ed5fc07438372ebea1acde63e3e52f1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcd/javacard/cre_apt_edcd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/Cre_Apt_Edcr_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/Cre_Apt_Edcr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..cfad2591d1aebc3e7b9c7ec5d129b537720989e2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/Cre_Apt_Edcr_1.java @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edcr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edcr; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_DOWNLOAD CARD READER STATUS + * + * + * + * + * + */ + +public class Cre_Apt_Edcr_1 extends TestToolkitApplet{ + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + //private static ToolkitRegistry obReg; + + //Constructor of the applet + public Cre_Apt_Edcr_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edcr_1 thisApplet = new Cre_Apt_Edcr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_DOWNLOAD CARD READER STATUS + //obReg =ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + if(event==EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:UNREGISTER THE APPLET TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5:THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4:REGISTER THE APPLET TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + obReg.setEvent(EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/Test_Cre_Apt_Edcr.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/Test_Cre_Apt_Edcr.java new file mode 100644 index 0000000000000000000000000000000000000000..91303e2c60a19cfabd8b5435e3db447f0bee3965 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/Test_Cre_Apt_Edcr.java @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_DOWNLOAD CARD READER STATUS +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edcr; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edcr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edcr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edcr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 81"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadCardReaderStatus(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadCardReaderStatus(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS *** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadCardReaderStatus(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2ba4113a01d0f95fc6986b7e7a364d5b7acddd33 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edcr.Cre_Apt_Edcr_1 +uicc.test.catre.cre_apt_edcr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/javacard/cre_apt_edcr.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/javacard/cre_apt_edcr.cap new file mode 100644 index 0000000000000000000000000000000000000000..229e6af4e9f6e38da871284c7e3d07f29909e972 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcr/javacard/cre_apt_edcr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/Cre_Apt_Edcs_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/Cre_Apt_Edcs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7e637687e491608a0992da8904e657e82ac178bc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/Cre_Apt_Edcs_1.java @@ -0,0 +1,258 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edcs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edcs; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + * + * + * + * + */ +public class Cre_Apt_Edcs_1 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x01; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + public final static byte QUALIFIER_1 = (byte)0x01; + public final static byte QUALIFIER_2 = (byte)0x02; + public static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + public static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + public static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + + /* Constructor of the applet */ + public Cre_Apt_Edcs_1() { + + } + + + /* Method called by the JCRE at the installation of the applet */ + public static void install (byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instace + Cre_Apt_Edcs_1 thisApplet = new Cre_Apt_Edcs_1(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + } + + + /* Method called by the UICC CAT Runtime Environment*/ + public void processToolkit(short event) { + + bRes=false; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + + if (event==EVENT_MENU_SELECTION) { + + switch(testCaseNb) { + /* Test Case 1: Applet Registration to EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x01: + // 2-The applet is registered to EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + try { + obReg.setEvent(EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS); + bRes=true; + } + catch(Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x02; + + // 3- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x03; + break; + + case (byte)0x03: + /* 5- Open a channel with init() method + type = Open Channel + qualifier = 01 + dstDevice = ME */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + // 6- send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x04; + + // 8- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x05; + break; + + case (byte)0x05: + /* 10- Open a channel with init() method + type = Open Channel + qualifier = 01 + dstDevice = ME */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + + // 11- send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x06; + break; + /* Test Case 3: Applet Deregistration to EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x07: + /* 1- Open a channel with init() method + type = Open Channel + qualifier = 02 + dstDevice = ME */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_2, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + // send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x08; + // 2- Close the opened channel unsuccessfully + try { + proHdlr.initCloseChannel((byte)0x02); + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x09; + break; + /* Test Case 5: The applet is not triggered after a reset */ + case (byte)0x0B: + /* 1- Open a channel with init() method + type = Open Channel + qualifier = 01 + dstDevice = ME */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + // 2- send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0C; + // 3- isEventSet() + bRes = obReg.isEventSet(EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS); + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0D; + // 5- The applet is not triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + bRes=true; + reportTestOutcome(testCaseNb, bRes); + break; + + } + } + + if (event==EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS) { + + switch(testCaseNb) { + /* Test Case 1: 3/8- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x03: + bRes=false; + testCaseNb = (byte) 0x02; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x03; + break; + case (byte)0x05: + bRes=false; + testCaseNb = (byte) 0x04; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x05; + break; + /* Test Case 2: The applet is triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x06 : + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x07; + break; + /* Test Case 3: Applet Deregistration to EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x09: + // 4- Close the opened channel successfully + try { + proHdlr.initCloseChannel((byte)0x02); + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0A; + /* Test Case 4: 1- The applet is not triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0B; + break; + /* Test Case 4: 1- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x0B: + bRes=false; + testCaseNb = (byte) 0x0A; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0B; + break; + /* Test Case 5: 5- The applet is not triggered by EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS */ + case (byte)0x0D: + bRes=false; + reportTestOutcome(testCaseNb, bRes); + break; + } + } + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/Test_Cre_Apt_Edcs.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/Test_Cre_Apt_Edcs.java new file mode 100644 index 0000000000000000000000000000000000000000..16642749998c5e536abc11cad3b62dc223e5049a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/Test_Cre_Apt_Edcs.java @@ -0,0 +1,154 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edcs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edcs extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edcs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edcs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "02" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED BY EVENT_FIRST_COMMAND_AFTER_ATR, + //*** 2-APPLET 2 IS TRIGGERED BY EVENT_PROFILE_DONWLOAD + //*** 3_APPLET 3 IS NOT TRIGGERED + test.terminalProfileSession("09010020 000C0000 00000003 40"); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result = response.checkSw("9000"); + + //***TEST CASE 1: 3-APPLET 1 IS NOT TRIGGERED BY EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("9000"); + + //***TEST CASE 1: 4-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + //TERMINAL RESPONSE WITH PROACTIVE UICC SESSION TERMINATED BY USER + test.terminalResponse("81030140 01820282 81830110"); + + //***TEST CASE 1: 8-APPLET 1 IS NOT TRIGGERED BY EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38020100"); + result &= response.checkSw("9000"); + + //***TEST CASE 1: 9-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + //APPLET 1 BUILD A PROACTIVE COMMAND OPEN CHANNEL + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + //SUCCESSFUL TERMINAL RESPONSE + response = test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + result &= response.checkSw("9000"); + + //***TEST CASE 2: 1-APPLET 1 IS TRIGGERED BY EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("9000"); + + //***TEST CASE 3: 1-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + //APPLET 1 BUILD A PROACTIVE COMMAND OPEN CHANNEL + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400282 02818206 05815566" + + "77883502 03003902 000A"); + //TERMINAL RESPONSE WITH PARTIAL COMPREHENSION + response = test.terminalResponse("81030140 02820282 81830101 38028200" + + "35020300 3902000A"); + result &= response.checkSw("910B"); + //APPLET 1 BUILD A PROACTIVE COMMAND CLOSE CHANNEL + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028122"); + //UNSUCCESSFUL TERMINAL RESPONSE: TERMINAL CURRENTLY UNABLE TO PERFORM THE COMMAND + response = test.terminalResponse("81030141 00820282 81830120"); + result &= response.checkSw("9000"); + + //***TEST CASE 3: 4-APPLET 1 IS TRIGGERED BY EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38028200"); + result &= response.checkSw("910B"); + //APPLET 1 BUILD A PROACTIVE COMMAND CLOSE CHANNEL + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028122"); + //TERMINAL RESPONSE WITH MISSING INFORMATION + response = test.terminalResponse("81030141 00820282 81830102"); + result &= response.checkSw("9000"); + + //***TEST CASE 4: 4-APPLET 1 IS NOT TRIGGERED BY EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38028200"); + result &= response.checkSw("9000"); + + //***TEST CASE 5: 1-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + //APPLET 1 BUILD A PROACTIVE COMMAND OPEN CHANNEL + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + //SUCCESSFUL TERMINAL RESPONSE + test.terminalResponse("81030140 01820282 81830100 38028200" + + "35020300 3902000A"); + result &= response.checkSw("9000"); + test.reset(); + test.terminalProfileSession("09010020 000C0000 00000003 40"); + response = test.envelopeEventDownloadChannelStatus("38028200"); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c262122d115834ee2b7331233e08d09d08152fcb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edcs.Cre_Apt_Edcs_1 +uicc.test.catre.cre_apt_edcs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/javacard/cre_apt_edcs.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/javacard/cre_apt_edcs.cap new file mode 100644 index 0000000000000000000000000000000000000000..f51f87b9c293608a154942e094eb9c5dc07c21fb Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edcs/javacard/cre_apt_edcs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/Cre_Apt_Edda_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/Cre_Apt_Edda_1.java new file mode 100644 index 0000000000000000000000000000000000000000..797f6ab9201fda51005803921770077324d6601a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/Cre_Apt_Edda_1.java @@ -0,0 +1,261 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edda_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edda; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + * + * + * + * + */ + +public class Cre_Apt_Edda_1 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x01; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + public final static byte QUALIFIER_1 = (byte)0x01; + public final static byte QUALIFIER_2 = (byte)0x02; + public static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + public static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + public static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + + /* Constructor of the applet */ + public Cre_Apt_Edda_1() { + + } + + + /* Method called by the JCRE at the installation of the applet */ + public static void install (byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Apt_Edda_1 thisApplet = new Cre_Apt_Edda_1(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + } + + + /* Method called by the UICC CAT RE */ + public void processToolkit(short event) { + + bRes=false; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + + if (event==EVENT_MENU_SELECTION) { + + switch(testCaseNb) { + /* Test Case 1: Applet Registration to EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x01: + // 2-The applet is registered to EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + try { + obReg.setEvent(EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE); + bRes=true; + } + catch(Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x02; + + // 3- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x03; + break; + + case (byte)0x03: + /* 5- Open a channel with init() method + type = Open Channel + qualifier = 01 + dstDevice = TERMINAL */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)ADDRESS_VALUE.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)BEARER_VALUE.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)BUFFER_SIZE_VALUE.length); + // 6- send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x04; + + // 8- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x05; + break; + + case (byte)0x05: + /* 10- Open a channel with init() method + type = Open Channel + qualifier = 01 + dstDevice = TERMINAL */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)ADDRESS_VALUE.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)BEARER_VALUE.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)BUFFER_SIZE_VALUE.length); + + // 11- send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x06; + break; + /* Test Case 3: Applet Deregistration to EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x07: + /* 1- Open a channel with init() method + type = Open Channel + qualifier = 02 + dstDevice = TERMINAL */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_2, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)ADDRESS_VALUE.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)BEARER_VALUE.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)BUFFER_SIZE_VALUE.length); + + + + // send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x08; + // 2- Close the opened channel unsuccessfully + try { + proHdlr.initCloseChannel((byte)0x02); + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x09; + break; + /* Test Case 5: The applet is not triggered after a reset */ + case (byte)0x0B: + /* 1- Open a channel with init() method + type = Open Channel + qualifier = 01 + dstDevice = TERMINAL */ + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)ADDRESS_VALUE.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)BEARER_VALUE.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)BUFFER_SIZE_VALUE.length); + // 2- send() method is called + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0C; + // 3- isEventSet() + bRes = obReg.isEventSet(EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE); + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0D; + // 5- The applet is not triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + bRes=true; + reportTestOutcome(testCaseNb, bRes); + break; + + } + } + + if (event==EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE) { + + switch(testCaseNb) { + /* Test Case 1: 3/8- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x03: + bRes=false; + testCaseNb = (byte) 0x02; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x03; + break; + case (byte)0x05: + bRes=false; + testCaseNb = (byte) 0x04; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x05; + break; + /* Test Case 2: The applet is triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x06 : + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x07; + break; + /* Test Case 3: Applet Deregistration to EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x09: + // 4- Close the opened channel successfully + try { + proHdlr.initCloseChannel((byte)0x02); + proHdlr.send(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0A; + /* Test Case 4: 1- The applet is not triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + bRes=true; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0B; + break; + /* Test Case 4: 1- The applet shall not be triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x0B: + bRes=false; + testCaseNb = (byte) 0x0A; + reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte) 0x0B; + break; + /* Test Case 5: 5- The applet is not triggered by EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE */ + case (byte)0x0D: + bRes=false; + reportTestOutcome(testCaseNb, bRes); + break; + } + } + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/Test_Cre_Apt_Edda.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/Test_Cre_Apt_Edda.java new file mode 100644 index 0000000000000000000000000000000000000000..f8aa56e1b83e57095c62d3a698e889c78b35781d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/Test_Cre_Apt_Edda.java @@ -0,0 +1,154 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DATA_DOWNLOAD_AVAILABLE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edda; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edda extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edda"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edda() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "02" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED BY EVENT_FIRST_COMMAND_AFTER_ATR, + //*** 2-APPLET 2 IS TRIGGERED BY EVENT_PROFILE_DONWLOAD + //*** 3_APPLET 3 IS NOT TRIGGERED + test.terminalProfileSession("09010020 000C0000 00000003 40"); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result = response.checkSw("9000"); + + //***TEST CASE 1: 3-APPLET 1 IS NOT TRIGGERED BY EVENT_EVENT_DATA_DOWNLOAD_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38028100"); + result &= response.checkSw("9000"); + + //***TEST CASE 1: 4-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + //TERMINAL RESPONSE WITH PROACTIVE UICC SESSION TERMINATED BY USER + test.terminalResponse("81030140 01820282 81830110"); + + //***TEST CASE 1: 8-APPLET 1 IS NOT TRIGGERED BY EVENT_EVENT_DATA_DOWNLOAD_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38020100"); + result &= response.checkSw("9000"); + + //***TEST CASE 1: 9-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + //APPLET 1 BUILD A PROACTIVE COMMAND OPEN CHANNEL + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + //SUCCESSFUL TERMINAL RESPONSE + response = test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + result &= response.checkSw("9000"); + + //***TEST CASE 2: 1-APPLET 1 IS TRIGGERED BY EVENT_EVENT_DATA_DOWNLOAD_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38028100"); + result &= response.checkSw("9000"); + + //***TEST CASE 3: 1-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + //APPLET 1 BUILD A PROACTIVE COMMAND OPEN CHANNEL + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400282 02818206 05815566" + + "77883502 03003902 000A"); + //TERMINAL RESPONSE WITH PARTIAL COMPREHENSION + response = test.terminalResponse("81030140 02820282 81830101 38028200" + + "35020300 3902000A"); + result &= response.checkSw("910B"); + //APPLET 1 BUILD A PROACTIVE COMMAND CLOSE CHANNEL + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028122"); + //UNSUCCESSFUL TERMINAL RESPONSE: TERMINAL CURRENTLY UNABLE TO PERFORM THE COMMAND + response = test.terminalResponse("81030141 00820282 81830120"); + result &= response.checkSw("9000"); + + //***TEST CASE 3: 4-APPLET 1 IS TRIGGERED BY EVENT_EVENT_DATA_DOWNLOAD_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38028200"); + result &= response.checkSw("910B"); + //APPLET 1 BUILD A PROACTIVE COMMAND CLOSE CHANNEL + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028122"); + //TERMINAL RESPONSE WITH MISSING INFORMATION + response = test.terminalResponse("81030141 00820282 81830102"); + result &= response.checkSw("9000"); + + //***TEST CASE 4: 4-APPLET 1 IS NOT TRIGGERED BY EVENT_EVENT_DATA_DOWNLOAD_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38028200"); + result &= response.checkSw("9000"); + + //***TEST CASE 5: 1-APPLET 1 IS TRIGGERED BY EVENT MENU SELECTION + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("911A"); + //APPLET 1 BUILD A PROACTIVE COMMAND OPEN CHANNEL + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + //SUCCESSFUL TERMINAL RESPONSE + response = test.terminalResponse("81030140 01820282 81830100 38028200" + + "35020300 3902000A"); + result &= response.checkSw("9000"); + test.reset(); + test.terminalProfileSession("09010020 000C0000 00000003 40"); + response = test.envelopeEventDownloadDataAvailable("38028200"); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9f115115c57e8ff95809f8db3689a9940077497d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edda.Cre_Apt_Edda_1 +uicc.test.catre.cre_apt_edda +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/javacard/cre_apt_edda.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/javacard/cre_apt_edda.cap new file mode 100644 index 0000000000000000000000000000000000000000..fb16fcbe1fccd9c145655fd16c2ba9b92074c577 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edda/javacard/cre_apt_edda.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/Cre_Apt_Eddp_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/Cre_Apt_Eddp_1.java new file mode 100644 index 0000000000000000000000000000000000000000..9ecf45aaa759792bfae16925a87ba92839ec5937 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/Cre_Apt_Eddp_1.java @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Eddp_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_eddp; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + * + * + * + * + * + */ + +public class Cre_Apt_Eddp_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + //private static ToolkitRegistry obReg; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + + //Constructor of the applet + + public Cre_Apt_Eddp_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Eddp_1 thisApplet = new Cre_Apt_Eddp_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + // obReg = ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + if(event==EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5:THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + obReg.setEvent(EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/Test_Cre_Apt_Eddp.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/Test_Cre_Apt_Eddp.java new file mode 100644 index 0000000000000000000000000000000000000000..e3404bdeaebcb60918e2960dc25144d7634aafba --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/Test_Cre_Apt_Eddp.java @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_eddp; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Eddp extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_eddp"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Eddp() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 0120"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED*** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadDisplayParametersChanged(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadDisplayParametersChanged(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED*** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadDisplayParametersChanged(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6efe13b7d85076e2d19d398523fa67d3db620f24 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_eddp.Cre_Apt_Eddp_1 +uicc.test.catre.cre_apt_eddp +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/javacard/cre_apt_eddp.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/javacard/cre_apt_eddp.cap new file mode 100644 index 0000000000000000000000000000000000000000..4c773b2678a60742af34adb5134d65b6e2ab9594 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eddp/javacard/cre_apt_eddp.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/Cre_Apt_Edis_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/Cre_Apt_Edis_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ba4e55b253b612b4d4fce35777d4967fa338d26a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/Cre_Apt_Edis_1.java @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edis_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edis; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + * + * + * + * + * + */ + +public class Cre_Apt_Edis_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + //private static ToolkitRegistry obReg; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + + //Constructor of the applet + + public Cre_Apt_Edis_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edis_1 thisApplet = new Cre_Apt_Edis_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD IDLE SCREEN AVAILABLE + //obReg = ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + + //event EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + if(event==EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: UNREGISTER THE APPLET TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: REGISTER THE APPLET TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //Register to EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + obReg.setEvent(EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/Test_Cre_Apt_Edis.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/Test_Cre_Apt_Edis.java new file mode 100644 index 0000000000000000000000000000000000000000..a6b159e88bd4d0f48850df8aa3d5417974e83286 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/Test_Cre_Apt_Edis.java @@ -0,0 +1,79 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edis; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edis extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edis"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edis() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 41"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadIdleScreenAvailable(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadIdleScreenAvailable(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE *** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadIdleScreenAvailable(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..0166d5d2e36639e7ac5bb87c9655a934c7524dc8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edis.Cre_Apt_Edis_1 +uicc.test.catre.cre_apt_edis +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/javacard/cre_apt_edis.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/javacard/cre_apt_edis.cap new file mode 100644 index 0000000000000000000000000000000000000000..d93d476def59867a2bf458071eb038621d181f5e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edis/javacard/cre_apt_edis.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/Cre_Apt_Edlc_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/Cre_Apt_Edlc_1.java new file mode 100644 index 0000000000000000000000000000000000000000..393050305093851f39845abfdcbfad56e1ec8ee8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/Cre_Apt_Edlc_1.java @@ -0,0 +1,245 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edlg_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edlc; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_LOCAL CONNECTION + * + * + * + * + * + */ + + public class Cre_Apt_Edlc_1 extends TestToolkitApplet{ + + private static boolean bRes; + private byte testCaseNb = (byte) 0x00; + private static byte servId = (byte) 0x00; + + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + private static byte[] serviceRecord={(byte)0x00,(byte)0x00,(byte)0x00}; + + + //Constructor of the applet + public Cre_Apt_Edlc_1(){ + + } + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + //Create a new applet instace + Cre_Apt_Edlc_1 thisApplet = new Cre_Apt_Edlc_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_EVENT_DOWNLOAD_LOCAL CONNECTION + for (byte sId=0; sId < 8; sId++) + { + thisApplet.obReg.allocateServiceIdentifier(); + } + for (byte sId=1; sId < 8; sId++) + { + thisApplet.obReg.releaseServiceIdentifier(sId); + } + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + } + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 1: 1 - Applet is triggered + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:2 - Method returns true + testCaseNb=(byte)0x02; + try{ + //check if registered to the event EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + bRes=obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:3 - Applet is not triggered + testCaseNb=(byte)0x03; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x03: + //TEST CASE 1:4 - Applet is triggered by the envelope menu selection + testCaseNb=(byte)0x04; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + try{ + //TEST CASE 1:5 - Declare service (add) proactive command + testCaseNb=(byte)0x05; + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte)0x00,(byte)0x82); + prHdlr.appendTLV(TAG_SERVICE_RECORD,serviceRecord,(short) 0,(short) serviceRecord.length); + prHdlr.send(); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:6 - Applet is not triggered + testCaseNb=(byte)0x06; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + case(byte)0x06: + //TEST CASE 1:7 - Applet is triggered by the envelope menu selection + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + try{ + //TEST CASE 1:8 - Declare service (add) proactive command + testCaseNb=(byte)0x08; + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte)0x00,(byte)0x82); + prHdlr.appendTLV(TAG_SERVICE_RECORD,serviceRecord,(short) 0,(short) serviceRecord.length); + prHdlr.send(); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + break; + case(byte)0x09: + //TEST CASE 3:1 - Applet is triggered + testCaseNb=(byte)0x0A; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + try{ + //TEST CASE 3:2 - Declare service (delete) proactive command + testCaseNb=(byte)0x0B; + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte)0x01,(byte)0x82); + prHdlr.appendTLV(TAG_SERVICE_RECORD,serviceRecord,(short)0,(short)serviceRecord.length); + prHdlr.send(); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x0E: + //TEST CASE 5:1 - Applet is triggered + testCaseNb=(byte)0x0F; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + try{ + //TEST CASE 5:2 - Declare service (add) proactive command + testCaseNb=(byte)0x10; + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte)0x00,(byte)0x82); + prHdlr.appendTLV(TAG_SERVICE_RECORD,serviceRecord,(short)0,(short)serviceRecord.length); + prHdlr.send(); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + break; + } + } + + //event EVENT_EVENT_DOWNLOAD_LOCAL CONNECTION + if(event==EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION){ + switch(testCaseNb){ + case (byte)0x03: + bRes=false; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x03; + break; + case (byte)0x06: + bRes=false; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x06; + break; + case (byte)0x08: + //TEST CASE 2:1 - Applet is triggered + testCaseNb=(byte)0x09; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x0B: + //TEST CASE 3:3 - Applet is triggered + testCaseNb=(byte)0x0C; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + try{ + //TEST CASE 3:4 - Declare service (delete) proactive command + testCaseNb=(byte)0x0D; + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte)0x01,(byte)0x82); + prHdlr.appendTLV(TAG_SERVICE_RECORD,serviceRecord,(short)0,(short)serviceRecord.length); + prHdlr.send(); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 4:1 - Applet is not triggered + testCaseNb=(byte)0x0E; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x0E: + testCaseNb=(byte)0x0E; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x10: + //TEST CASE 5:3 - Applet is triggered + testCaseNb=(byte)0x11; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 5:5 - Applet is not triggered + testCaseNb=(byte)0x12; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x12: + testCaseNb=(byte)0x12; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + } + + } + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/Test_Cre_Apt_Edlc.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/Test_Cre_Apt_Edlc.java new file mode 100644 index 0000000000000000000000000000000000000000..fc05399a15d0c8f1d2a8c8fd2537c12e71c3764f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/Test_Cre_Apt_Edlc.java @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_LOCAL CONNECTION +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edlc; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edlc extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edlc"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static String ServiceRecordTLV = "4103000000"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edlc() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "08"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("01010000 00010000 000000FF 5F"); + //***TEST CASE 1: 1-APPLET IS TRIGGERED + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 1: 2-METHOD isEventSet() RETURNS TRUE + //***TEST CASE 1: 3-APPLET IS NOT TRIGGERED + test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + //***TEST CASE 1: 4-APPLET IS TRIGGERED + response = test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 1: 5-DECLARE SERVICE ADD COMMAND IS FETCHED + result = response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470082 028182" + ServiceRecordTLV); + //UNSUCCESFULL TERMINAL RESPONSE with General Result = 0x20 + test.terminalResponse("81030147 00820282 81830120"); + //***TEST CASE 1: 6-APPLET IS NOT TRIGGERED + test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + //***TEST CASE 1: 7-APPLET IS TRIGGERED + response = test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE1: 8-DECLARE SERVICE ADD COMMAND IS FETCHED + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470082 028182" + ServiceRecordTLV); + //SUCCESFULL TERMINAL RESPONSE with General Result = 0x00 + test.terminalResponse("81030147 00820282 81830100"); + //***TEST CASE 2: 1-APPLET IS TRIGGERED + test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + //***TEST CASE 3: 1-APPLET IS TRIGGERED + response = test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 3: 2-DECLARE SERVICE DELETE COMMAND IS FETCHED + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470182 028182" + ServiceRecordTLV); + //UNSUCCESFULL TERMINAL RESPONSE with General Result = 0x20 + test.terminalResponse("81030147 01820282 81830120"); + //***TEST CASE 3: 3-APPLET IS TRIGGERED + response = test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + //***TEST CASE 3: 2-DECLARE SERVICE DELETE COMMAND IS FETCHED + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470182 028182" + ServiceRecordTLV); + //SUCCESFULL TERMINAL RESPONSE with General Result = 0x00 + test.terminalResponse("81030147 01820282 81830100"); + //***TEST CASE 4: 1-APPLET IS NOT TRIGGERED + test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + //***TEST CASE 5: 1-APPLET IS TRIGGERED + response = test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 5: 2-DECLARE SERVICE ADD COMMAND IS FETCHED + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470082 028182" + ServiceRecordTLV); + //SUCCESFULL TERMINAL RESPONSE with General Result = 0x00 + test.terminalResponse("81030147 00820282 81830100"); + //***TEST CASE 5: 3-APPLET IS TRIGGERED + test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + test.reset(); + test.terminalProfileSession("01010000 00010000 000000FF 5F"); + //***TEST CASE 5: 5-APPLET IS TRIGGERED + test.envelopeEventDownloadLocalConnection(ServiceRecordTLV); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"12CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ed6e573170a3a07a3bf4e4e70357198e81969c96 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edlc.Cre_Apt_Edlc_1 +uicc.test.catre.cre_apt_edlc +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/javacard/cre_apt_edlc.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/javacard/cre_apt_edlc.cap new file mode 100644 index 0000000000000000000000000000000000000000..cc9dd4c5a74847742eecaa6bb3595429ba1cfb2d Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlc/javacard/cre_apt_edlc.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/Cre_Apt_Edlg_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/Cre_Apt_Edlg_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d2339f81a47287e952ce6b9626d1a591261d6f08 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/Cre_Apt_Edlg_1.java @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edlg_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edlg; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + * + * + * + * + * + */ + + public class Cre_Apt_Edlg_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + //Constructor of the applet + + public Cre_Apt_Edlg_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edlg_1 thisApplet = new Cre_Apt_Edlg_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD LANGUAGE SELECTION + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + //register to the EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + if(event==EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to the event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + // Test Case 3 : THE APPLET MUST NOT BE TRIGGERED + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to the event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + obReg.setEvent(EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/Test_Cre_Apt_Edlg.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/Test_Cre_Apt_Edlg.java new file mode 100644 index 0000000000000000000000000000000000000000..371e940cfbea53e8dba5d536b868490932e05467 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/Test_Cre_Apt_Edlg.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edlg; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edlg extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edlg"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edlg() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 0001"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadLanguageSelection(); + test.terminalProfileSession("09010000 0101"); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadLanguageSelection(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + test.envelopeMenuSelection("100101", "");//Help Request not available + test.terminalProfileSession("09010000 0101"); + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadLanguageSelection(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2e35fc8d239cbdcf9bcfb113bc18481bbf52024e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edlg.Cre_Apt_Edlg_1 +uicc.test.catre.cre_apt_edlg +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/javacard/cre_apt_edlg.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/javacard/cre_apt_edlg.cap new file mode 100644 index 0000000000000000000000000000000000000000..f1488d37b65a878281886f1c6d0bfe210f848f99 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edlg/javacard/cre_apt_edlg.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/Cre_Apt_Edls_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/Cre_Apt_Edls_1.java new file mode 100644 index 0000000000000000000000000000000000000000..afca53c357bdf2a96b7e40f5dd272fd3dc5cb1c5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/Cre_Apt_Edls_1.java @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edls_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edls; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + * + * + * + * + * + */ + + + public class Cre_Apt_Edls_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + //private static ToolkitRegistry obReg; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + //Constructor of the applet + + public Cre_Apt_Edls_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edls_1 thisApplet = new Cre_Apt_Edls_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD LOCATION STATUS + // obReg = ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + if(event==EVENT_EVENT_DOWNLOAD_LOCATION_STATUS){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + bRes=false; + //TEST CASE 2: UNREGISTER THE APPLET TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //register to EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + obReg.setEvent(EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/Test_Cre_Apt_Edls.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/Test_Cre_Apt_Edls.java new file mode 100644 index 0000000000000000000000000000000000000000..4c63b39a4ada6d3f31c1b44e066ad05ffef3ab0f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/Test_Cre_Apt_Edls.java @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_LOCATION_STATUS +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edls; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edls extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edls"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edls() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 11"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_LOCATION_STATUS *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadLocationStatus(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadLocationStatus(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_LOCATION_STATUS *** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadLocationStatus(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..757ce4057bbf06b821d56f5ac56f6bd6a88a0e76 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edls.Cre_Apt_Edls_1 +uicc.test.catre.cre_apt_edls +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/javacard/cre_apt_edls.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/javacard/cre_apt_edls.cap new file mode 100644 index 0000000000000000000000000000000000000000..883309526dad84f377b943932984289301e81d96 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edls/javacard/cre_apt_edls.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/Cre_Apt_Edmc_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/Cre_Apt_Edmc_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ba3c45bfd1b0ba31ecb6a2ee57e4274a5f54f6ba --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/Cre_Apt_Edmc_1.java @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edmc_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edmc; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_MT_CALL + * + * + * + * + * + */ + + public class Cre_Apt_Edmc_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + //private static ToolkitRegistry obReg; + + + //Constructor of the applet + + public Cre_Apt_Edmc_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edmc_1 thisApplet = new Cre_Apt_Edmc_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD MT CALL + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + //Checks if the applet is registered to the event + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_MT_CALL); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + + + if(event==EVENT_EVENT_DOWNLOAD_MT_CALL){ + + switch(testCaseNb){ + + case (byte)0x00: + //TEST CASE 1: Store the result of the test if the applet is registered to the event + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + bRes=false; + //TEST CASE 2: The applet has been triggered and it's deregistered to the event + testCaseNb=(byte)0x02; + try{ + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + //TEST CASE 3: The applet must not be triggered in this case + //if the applet is triggered the the test is falled + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: The applet is triggered + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: The applet is registered to the Event Download MT Call event + testCaseNb=(byte)0x04; + try{ + obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/Test_Cre_Apt_Edmc.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/Test_Cre_Apt_Edmc.java new file mode 100644 index 0000000000000000000000000000000000000000..d7c0b92ef78cd448de786184bf34f4df2109483b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/Test_Cre_Apt_Edmc.java @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_MT_CALL +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edmc; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edmc extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edmc"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edmc() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 03"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_MT_CALL*** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadMTCall(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadMTCall(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_MT_CALL*** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadMTCall(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..08049b924f15cc36bbbb17936e1955d8e8a9d923 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edmc.Cre_Apt_Edmc_1 +uicc.test.catre.cre_apt_edmc +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/javacard/cre_apt_edmc.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/javacard/cre_apt_edmc.cap new file mode 100644 index 0000000000000000000000000000000000000000..298b61ce7049707462ac7bb0ab3a0dfec293d08e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edmc/javacard/cre_apt_edmc.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/Cre_Apt_Edns_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/Cre_Apt_Edns_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1d7541a597fd8fd2faf5771f3ba0f5a3cf13ca72 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/Cre_Apt_Edns_1.java @@ -0,0 +1,122 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edns_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edns; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + * + * + * + * + * + */ + + public class Cre_Apt_Edns_1 extends TestToolkitApplet{ + + private static boolean bRes; + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'1'}; + + //Constructor of the applet + public Cre_Apt_Edns_1(){ + + } + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + //Create a new applet instace + Cre_Apt_Edns_1 thisApplet = new Cre_Apt_Edns_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + try{bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE);} + catch(Exception e){bRes=false;} + } + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + EnvelopeHandler envHndlr = EnvelopeHandlerSystem.getTheHandler(); + //event EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + if(event==EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE){ + //TEST CASE 1: 1 - METHOD isEventSet() RETURNS TRUE + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:2 - Applet is triggered + testCaseNb=(byte)0x02; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + + //TEST CASE 2: METHOD clearEvent() IS CALLED + testCaseNb=(byte)0x03; + try{ + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: 1 - APPLET IS NOT TRIGGERED + testCaseNb=(byte)0x04; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2: 1 - IF APPLET IS TRIGGERED WRONGLY + case (byte)0x04: + testCaseNb=(byte)0x04; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2: 3 - APPLET IS TRIGGERED + case (byte)0x06: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + }//end of switch + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + switch(testCaseNb){ + //TEST CASE 2:2 - APPLET IS TRIGGERED + case (byte)0x04: + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //setEvent() doesn't throws any exception + testCaseNb=(byte)0x06; + try{ + obReg.setEvent(EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/Test_Cre_Apt_Edns.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/Test_Cre_Apt_Edns.java new file mode 100644 index 0000000000000000000000000000000000000000..fdbc2c4b3cbdf493437561f139e323ffd661bb96 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/Test_Cre_Apt_Edns.java @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edns; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edns extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edns"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edns() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("01010000 01010000 000000FF 5F"); + //***TEST CASE 1: 2-APPLET IS TRIGGERED + test.envelopeEventDownloadNetworkSearchModeChange(); + //***TEST CASE 2: 1-APPLET IS NOT TRIGGERED + test.envelopeEventDownloadNetworkSearchModeChange(); + //***TEST CASE 2: 2-APPLET IS TRIGGERED + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 3-APPLET IS TRIGGERED + test.envelopeEventDownloadNetworkSearchModeChange(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..bf4e4c74b4d2f982fecf9d9b1fcf7a93ce8c6517 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edns.Cre_Apt_Edns_1 +uicc.test.catre.cre_apt_edns +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/javacard/cre_apt_edns.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/javacard/cre_apt_edns.cap new file mode 100644 index 0000000000000000000000000000000000000000..a17a29a5b671778b73fdc56acf80f7e587f50929 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edns/javacard/cre_apt_edns.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/Cre_Apt_Edua_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/Cre_Apt_Edua_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a1415c433249b30b6ecb3b448303aa00aded2919 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/Cre_Apt_Edua_1.java @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Edua_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_edua; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + * + * + * + * + * + */ + +public class Cre_Apt_Edua_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + + //Constructor of the applet + + public Cre_Apt_Edua_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Edua_1 thisApplet = new Cre_Apt_Edua_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT DOWNLOAD USER ACTIVITY + // obReg = ToolkitRegistry.getEntry(); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + //register to the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + bRes=thisApplet.obReg.isEventSet(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + //event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + if(event==EVENT_EVENT_DOWNLOAD_USER_ACTIVITY){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to the event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: THE APPLET MUST BE TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to the event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/Test_Cre_Apt_Edua.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/Test_Cre_Apt_Edua.java new file mode 100644 index 0000000000000000000000000000000000000000..a9cc989697129d4ae8fd697b67a72163facd1a1d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/Test_Cre_Apt_Edua.java @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EVENT_DOWNLOAD_USER_ACTIVITY +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_edua; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Edua extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_edua"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Edua() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 21"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_USER_ACTIVITY *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadUserActivity(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeEventDownloadUserActivity(); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + test.envelopeMenuSelection("100101", "");//Help Request not available; + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadUserActivity(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..0393e598d39fd1f1e76bfdff7bdf3516846fbab2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_edua.Cre_Apt_Edua_1 +uicc.test.catre.cre_apt_edua +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/javacard/cre_apt_edua.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/javacard/cre_apt_edua.cap new file mode 100644 index 0000000000000000000000000000000000000000..c9339c949a01140f4a65ab3d379cde5b9bf8c4e2 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_edua/javacard/cre_apt_edua.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/Cre_Apt_Eefu_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/Cre_Apt_Eefu_1.java new file mode 100644 index 0000000000000000000000000000000000000000..bd87aa6cf3bb5f8696c408d3fb7a8313c26b1a98 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/Cre_Apt_Eefu_1.java @@ -0,0 +1,336 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Eefu_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_eefu; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.access.* ; +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_EXTERNAL_FILE_UPDATE + * + * + * + * + * + */ + + public class Cre_Apt_Eefu_1 extends TestToolkitApplet{ + + private static boolean bRes; + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'1'}; + private static byte[] fileList1 ={(byte)0x02,(byte)0x3F, (byte)0x00, (byte)0x7F, (byte)0x4A, (byte)0x6F, (byte)0x0C, + (byte)0x3F, (byte)0x00, (byte)0x7F, (byte)0x4A, (byte)0x6F, (byte)0x09}; + private static byte[] fileList2 ={(byte)0x01,(byte)0x3F, (byte)0x00, (byte)0x7F, (byte)0x4A, (byte)0x6F, (byte)0x0C}; + private static byte[] baADFAid =null; + private static byte[] resp1 ={(byte)0, (byte)0,(byte)0,(byte)0,(byte)0,}; + private static byte[] resp2 ={(byte)0, (byte)0,(byte)0,(byte)0,(byte)0,}; + private static byte[] resp3 ={(byte)0, (byte)0,(byte)0,(byte)0,(byte)0,}; + private FileView theUiccView; + + + + //Constructor of the applet + public Cre_Apt_Eefu_1(){ + + } + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + //Create a new applet instace + Cre_Apt_Eefu_1 thisApplet = new Cre_Apt_Eefu_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + + } + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + theUiccView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 1: 1 - Applet is triggered + switch(testCaseNb){ + case (byte)0x00: + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:2 - METHOD isEventSet() RETURNS FALSE + testCaseNb=(byte)0x02; + try{ + bRes=!obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:3 - No exception is thrown + testCaseNb=(byte)0x03; + if(theUiccView!=null){ + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TARU); + try{ + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,theUiccView); + bRes=true; + } + catch(Exception e){bRes=false;} + } + else{bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:4 - METHOD isEventSet() RETURNS TRUE + testCaseNb=(byte)0x04; + try{bRes=obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE);} + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 1:5 - No exception is thrown + testCaseNb=(byte)0x05; + try{ + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,fileList1, (short)0x00,(short)fileList1.length, + baADFAid, (short)0x00, (byte)0x00); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 3: 1 - Applet is triggered + case (byte)0x14: + testCaseNb=(byte)0x15; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:2 - No exception is thrown + testCaseNb=(byte)0x16; + if(theUiccView!=null){ + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TARU); + try{ + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,theUiccView); + bRes=true; + } + catch(Exception e){bRes=false;} + } + else{bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:3 - No exception is thrown + testCaseNb=(byte)0x17; + try{ + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,fileList1, (short)0x00, + (short)fileList1.length, baADFAid, (short)0x00, (byte)0x00); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + break; + + + }//end of switch + } + + + //event EVENT_EXTERNAL_FILE_UPDATE + if(event==EVENT_EXTERNAL_FILE_UPDATE){ + switch(testCaseNb){ + //TEST CASE 1:6 - APPLET IS TRIGGERED on UPDATE EFtaru + case (byte)0x05: + testCaseNb=(byte)0x06; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 1:7 - APPLET IS TRIGGERED on UPDATE EFlaru + case (byte)0x06: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 1:8 - APPLET IS TRIGGERED on INCREASE EFcaru + case (byte)0x07: + testCaseNb=(byte)0x08; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2: 1 - APPLET IS TRIGGERED on UPDATE EFtaru + case (byte)0x08: + testCaseNb=(byte)0x09; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TARU); + theUiccView.readBinary((short) 0, resp1,(short) 0,(short) resp1.length); + + //TEST CASE 2: 2 - No exception is thrown + testCaseNb=(byte)0x0A; + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_CARU); + try{ + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE,theUiccView); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:3 - METHOD isEventSet() RETURNS TRUE + testCaseNb=(byte)0x0B; + try{bRes=obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE);} + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:4 - APPLET IS NOT TRIGGERED on INCREASE EFcaru + testCaseNb=(byte)0x0C; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2:5 - APPLET IS TRIGGERED on UPDATE EFtaru + case (byte) 0x0C: + testCaseNb=(byte)0x0D; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //Check to see if the triggering is on this event or on the previous one + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TARU); + theUiccView.readBinary((short) 0, resp2,(short) 0,(short) resp2.length); + if(Util.arrayCompare(resp1, (short)0, resp2, (short)0, (short)resp2.length)==0){ + testCaseNb=(byte)0x0C; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + } + + //TEST CASE 2:6 - No Exception is thrown + testCaseNb=(byte)0x0E; + try{obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE,fileList2, (short)0x00, + (short)fileList2.length, baADFAid, (short)0x00, (byte)0x00); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:7 - METHOD isEventSet() RETURNS TRUE + testCaseNb=(byte)0x0F; + try{bRes=obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE);} + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:8 - APPLET IS NOT TRIGGERED on UPDATE EFlaru + testCaseNb=(byte)0x10; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2:9 - APPLET IS TRIGGERED on UPDATE EFtaru + case (byte)0x10: + testCaseNb=(byte)0x11; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //Check to see if the triggering is on this event or on the previous one + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TARU); + theUiccView.readBinary((short) 0, resp3,(short) 0,(short) resp3.length); + if(Util.arrayCompare(resp2, (short)0, resp3, (short)0, (short)resp3.length)==0){ + testCaseNb=(byte)0x10; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + } + + //TEST CASE 2: 10 - No exception is thrown + testCaseNb=(byte)0x12; + theUiccView.select(UICCTestConstants.FID_DF_TEST); + theUiccView.select(UICCTestConstants.FID_EF_TARU); + try{obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE,theUiccView); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:11 - METHOD isEventSet() RETURNS FALSE + testCaseNb=(byte)0x13; + try{bRes=!obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE);} + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2:12 - APPLET IS NOT TRIGGERED on UPDATE EFtaru + testCaseNb=(byte)0x14; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 2:12 - APPLET IS TRIGGERED on UPDATE EFtaru WRONGLY + case (byte)0x14: + testCaseNb=(byte)0x14; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 3:4 - APPLET IS TRIGGERED on UPDATE EFtaru + case (byte)0x17: + testCaseNb=(byte)0x18; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 3:5 - APPLET IS TRIGGERED on UPDATE EFlaru + case (byte)0x18: + testCaseNb=(byte)0x19; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 3:6 - APPLET IS TRIGGERED on INCREASE EFcaru + case (byte)0x19: + testCaseNb=(byte)0x1A; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:7 - No Exception is thrown + testCaseNb=(byte)0x1B; + try{obReg.clearEvent(EVENT_EXTERNAL_FILE_UPDATE); + bRes=true; + } + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:8 - METHOD isEventSet() RETURNS FALSE + testCaseNb=(byte)0x1C; + try{bRes=!obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE);} + catch(Exception e){bRes=false;} + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:9 - APPLET IS NOT TRIGGERED on UPDATE EFtaru + testCaseNb=(byte)0x1D; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:10 - APPLET IS NOT TRIGGERED on UPDATE EFlaru + testCaseNb=(byte)0x1E; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 3:11 - APPLET IS NOT TRIGGERED on UPDATE EFcaru + testCaseNb=(byte)0x1F; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x1C; + break; + //TEST CASE 3:9 - APPLET IS TRIGGERED on UPDATE EFtaru WRONGLY + case (byte)0x1C: + testCaseNb=(byte)0x1D; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 3:10 - APPLET IS TRIGGERED on UPDATE EFlaru WRONGLY + case (byte)0x1D: + testCaseNb=(byte)0x1E; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + //TEST CASE 3:11 - APPLET IS TRIGGERED on UPDATE EFcaru WRONGLY + case (byte)0x1E: + testCaseNb=(byte)0x1F; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/Test_Cre_Apt_Eefu.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/Test_Cre_Apt_Eefu.java new file mode 100644 index 0000000000000000000000000000000000000000..c104ca189c448735bfec09c55f06bce0624d42a5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/Test_Cre_Apt_Eefu.java @@ -0,0 +1,198 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_EXTERNAL_FILE_UPDATE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_eefu; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Eefu extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_eefu"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String FID_DF_TEST = "7F4A"; + static final String FID_EF_TARU = "6F03"; + static final String FID_EF_CARU = "6F09"; + static final String FID_EF_LARU = "6F0C"; + static final String data3_1 = "111213"; + static final String data3_2 = "212223"; + static final String data4_1 = "A1A2A3A4"; + static final String data4_2 = "B1B2B3B4"; + static final String data5_1 = "A1A2A3A4A5"; + static final String data5_2 = "B1B2B3B4B5"; + static final String data5_3 = "C1C2C3C4C5"; + + + + + + private UiccAPITestCardService test; + APDUResponse response; + String data5_1_ToRestore; + String data4_1_ToRestore; + String data3_1_ToRestore; + String data3_2_ToRestore; + + + + public Test_Cre_Apt_Eefu() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" ); // LV Access Domain DAP field + + + // test script + test.reset(); + test.terminalProfileSession("09010000"); + + //***TEST CASE 1: 1-APPLET IS TRIGGERED + test.envelopeMenuSelection("100101", "");//Help Request not available + test.selectFile(FID_DF_TEST); + + //***TEST CASE 1: 6-APPLET IS TRIGGERED + test.selectFile(FID_EF_TARU); + data5_1_ToRestore=test.readBinary("0000","05").getData(); + test.updateBinary("0000", data5_1); + + //***TEST CASE 1: 7-APPLET IS TRIGGERED + test.selectFile(FID_EF_LARU); + data4_1_ToRestore=test.readRecord("01","04","04").getData(); + test.updateRecord("01", "04", data4_1); + + //***TEST CASE 1: 8-APPLET IS TRIGGERED + test.selectFile(FID_EF_CARU); + data3_1_ToRestore=test.readRecord("00","03","03").getData(); + data3_2_ToRestore=test.readRecord("00","03","03").getData(); + + + //Must be correct in increase + //test.updateRecord("01", "03", data3); + + test.sendApdu("8032000003" + data3_1); + + //***TEST CASE 2: 1-APPLET IS TRIGGERED + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_1); + + //***TEST CASE 2: 4-APPLET IS NOT TRIGGERED + test.selectFile(FID_EF_CARU); + //Must be correct in increase + //test.updateRecord("01", "03", data3); + test.sendApdu("8032000003" + data3_2); + + //***TEST CASE 2: 5-APPLET IS TRIGGERED + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_2); + + //***TEST CASE 2: 8-APPLET IS NOT TRIGGERED + test.selectFile(FID_EF_LARU); + test.updateRecord("01", "04", data4_2); + + //***TEST CASE 2: 9-APPLET IS TRIGGERED + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_3); + + //***TEST CASE 2: 12-APPLET IS NOT TRIGGERED + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_3); + + //***TEST CASE 3: 1-APPLET IS TRIGGERED + test.envelopeMenuSelection("100101", "");//Help Request not available + + //***TEST CASE 3: 4-APPLET IS TRIGGERED + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_1); + + //***TEST CASE 3: 5-APPLET IS TRIGGERED + test.selectFile(FID_EF_LARU); + test.updateRecord("01", "04", data4_1); + + //***TEST CASE 3: 6-APPLET IS TRIGGERED + test.selectFile(FID_EF_CARU); + //Must be correct in increase + //test.updateRecord("01", "03", data3); + test.sendApdu("8032000003" + data3_1); + + //***TEST CASE 3: 9-APPLET IS NOT TRIGGERED + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_1); + + //***TEST CASE 3: 10-APPLET IS NOT TRIGGERED + test.selectFile(FID_EF_LARU); + test.updateRecord("01", "04", data4_1); + + //***TEST CASE 3: 11-APPLET IS NOT TRIGGERED + test.selectFile(FID_EF_CARU); + //Must be correct in increase + //test.updateRecord("01", "03", data3); + test.sendApdu("8032000003" + data3_1); + + + //RESTORE EF_TARU, EF_LARU, EF_CARU + test.selectFile(FID_EF_TARU); + test.updateBinary("0000", data5_1_ToRestore); + + test.selectFile(FID_EF_LARU); + test.updateRecord("01", "04", data4_1_ToRestore); + + test.selectFile(FID_EF_CARU); + test.updateRecord("00", "03", data3_1_ToRestore); + test.updateRecord("00", "03", data3_2_ToRestore); + + + + + + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"1FCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a463ac6c0d85d10d66563aeddd05d4c74c5b5211 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_eefu.Cre_Apt_Eefu_1 +uicc.test.catre.cre_apt_eefu +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/javacard/cre_apt_eefu.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/javacard/cre_apt_eefu.cap new file mode 100644 index 0000000000000000000000000000000000000000..9ea1e4a9591418970880e6507f05534cfe737e1a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_eefu/javacard/cre_apt_eefu.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1e85adffa988764c545ef8b46acb2f37d381d8a1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_1.java @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Efca_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_efca; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_FIRST_COMMAND_AFTER_ATR + * + * + * + * + */ + +public class Cre_Apt_Efca_1 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private byte nbCases =(byte)0x00; + protected static byte FirstBetweenApp1AndApp2=0; + + // Constructor of the applet + public Cre_Apt_Efca_1() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Apt_Efca_1 thisApplet = new Cre_Apt_Efca_1(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_FIRST_COMMAND_AFTER_ATR + thisApplet.obReg.setEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + } + + + // Method called by the UICC CAT Runtime Environment + public void processToolkit(short event) { + + bRes=false; + + if(event==EVENT_FIRST_COMMAND_AFTER_ATR) { + + switch(nbCases) { + case (byte)0x00: + // TEST CASE 1: The applet is triggered by EVENT_FIRST_COMMAND_AFTER_ATR + testCaseNb=(byte)0x01; + if (FirstBetweenApp1AndApp2 == 0) { + try{ + //The applet is deregistered to the event + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + FirstBetweenApp1AndApp2=1; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x02,true); + reportTestOutcome((byte)0x03,true); + nbCases++; + break; + + case (byte)0x01: + // Test Case 2: the applet shall not be triggered + testCaseNb=(byte)0x02; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + nbCases++; + break; + + case (byte)0x02: + // Test Case 3: the applet shall not be triggered + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + } + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_2.java new file mode 100644 index 0000000000000000000000000000000000000000..518a6e00f024e753447283034a3e5b190e6277bc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_2.java @@ -0,0 +1,100 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Efca_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_efca; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_FIRST_COMMAND_AFTER_ATR + * + * + * + * + */ + + public class Cre_Apt_Efca_2 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private byte nbCases =(byte)0x00; + + // Constructor of the applet + public Cre_Apt_Efca_2() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Apt_Efca_2 thisApplet = new Cre_Apt_Efca_2(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_PROFILE_DOWNLOAD + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + } + + + // Method called by the UICC CAT Runtime Environment + public void processToolkit(short event) { + + bRes=false; + + if(event==EVENT_PROFILE_DOWNLOAD) { + + switch(nbCases) { + case (byte)0x00: + // Test Case 1: The applet is triggered by EVENT_PROFILE_DOWNLOAD + testCaseNb=(byte)0x01; + if (Cre_Apt_Efca_1.FirstBetweenApp1AndApp2 == 1) { + try{ + //The applet is deregistered to the event + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x02,true); + reportTestOutcome((byte)0x03,true); + nbCases++; + break; + + case (byte)0x01: + // Test Case 2: the applet shall not be triggered + testCaseNb=(byte)0x02; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + nbCases++; + break; + + case (byte)0x02: + // Test Case 3: the applet shall not be triggered + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + } + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_3.java new file mode 100644 index 0000000000000000000000000000000000000000..81953c0ae0e1723489b6db6d46ac30161f4d6118 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_3.java @@ -0,0 +1,139 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Efca_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_efca; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_FIRST_COMMAND_AFTER_ATR + * + * + * + * + */ + + public class Cre_Apt_Efca_3 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private byte nbCases =(byte)0x00; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'3'}; + protected static byte FirstBetweenApp3AndApp4=0; + + + // Constructor of the applet + public Cre_Apt_Efca_3() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Apt_Efca_3 thisApplet = new Cre_Apt_Efca_3(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + } + + + // Method called by the UICC CAT Runtime Environment + public void processToolkit(short event) { + + bRes=false; + + switch(nbCases) { + case (byte)0x00: + // Test Case 1: The applet is triggered by EVENT_MENU_SELECTION + testCaseNb=(byte)0x01; + if (event==EVENT_MENU_SELECTION) { + try{ + //The applet is registered to the EVENT_FIRST_COMMAND_AFTER_ATR + obReg.setEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + } + reportTestOutcome(testCaseNb,bRes); + bRes=false; + nbCases++; + break; + + case (byte)0x01: + // Test Case 2: the applet is triggered by EVENT_FIRST_COMMAND_AFTER_ATR + testCaseNb=(byte)0x02; + if (event==EVENT_FIRST_COMMAND_AFTER_ATR) { + try{ + //The applet is registered to the event + obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + } + reportTestOutcome(testCaseNb,bRes); + bRes=false; + nbCases++; + break; + + case (byte)0x02: + // Test Case 2: the applet is triggered by EVENT_PROFILE_DOWNLOAD + testCaseNb=(byte)0x03; + if (event==EVENT_PROFILE_DOWNLOAD) { + bRes=true; + } else { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + bRes=false; + nbCases++; + break; + + + case (byte)0x03: + // Test Case 3, 1st result: the applet is triggered by EVENT_FIRST_COMMAND_AFTER_ATR + testCaseNb=(byte)0x04; + if ((event==EVENT_FIRST_COMMAND_AFTER_ATR) && (FirstBetweenApp3AndApp4 == 1)) { + bRes=true; + FirstBetweenApp3AndApp4 = 2; + } + reportTestOutcome(testCaseNb,bRes); + bRes=false; + nbCases++; + break; + + case (byte)0x04: + // Test Case 3, 2nd result: the applet is triggered by EVENT_PROFILE_DOWNLOAD + testCaseNb=(byte)0x05; + if ((event==EVENT_PROFILE_DOWNLOAD) && (FirstBetweenApp3AndApp4 == 3)) { + bRes=true; + + } + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_4.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_4.java new file mode 100644 index 0000000000000000000000000000000000000000..6a16b1cecf80891e66b635435ecff5f0edb9db94 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_4.java @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Efca_4.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_efca; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_FIRST_COMMAND_AFTER_ATR + * + * + * + * + */ + + public class Cre_Apt_Efca_4 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private byte nbCases =(byte)0x00; + + + // Constructor of the applet + public Cre_Apt_Efca_4() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Apt_Efca_4 thisApplet = new Cre_Apt_Efca_4(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_FIRST_COMMAND_AFTER_ATR + thisApplet.obReg.setEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + // Register to EVENT_PROFILE_DOWNLOAD + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + } + + + // Method called by the UICC CAT Runtime Environment + public void processToolkit(short event) { + + bRes=false; + + switch(nbCases) { + case (byte)0x00: + // Test Case 3, 1st result: the applet is triggered by EVENT_FIRST_COMMAND_AFTER_ATR + testCaseNb = (byte) 0x01; + if ((event==EVENT_FIRST_COMMAND_AFTER_ATR) && (Cre_Apt_Efca_3.FirstBetweenApp3AndApp4 == 0)) { + bRes=true; + Cre_Apt_Efca_3.FirstBetweenApp3AndApp4 = 1; + } + reportTestOutcome(testCaseNb,bRes); + bRes=false; + nbCases++; + break; + + case (byte)0x01: + // Test Case 4, 2nd result: the applet is triggered by EVENT_PROFILE_DOWNLOAD + testCaseNb = (byte) 0x02; + if ((event==EVENT_PROFILE_DOWNLOAD) && (Cre_Apt_Efca_3.FirstBetweenApp3AndApp4 == 2)) { + bRes=true; + Cre_Apt_Efca_3.FirstBetweenApp3AndApp4 = 3; + } + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_5.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_5.java new file mode 100644 index 0000000000000000000000000000000000000000..d888264cc5abd9ffbb36414499120d4563eaae7e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Cre_Apt_Efca_5.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Efca_5.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_efca; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_FIRST_COMMAND_AFTER_ATR + * + * + * + * + */ + + public class Cre_Apt_Efca_5 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private byte nbCases =(byte)0x00; + private static byte result = (byte)0x00; + + private static byte [] Menu1 = + { (byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '1'}; + private static byte [] Menu2 = + { (byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '2'}; + + + // Constructor of the applet + public Cre_Apt_Efca_5() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Apt_Efca_5 thisApplet = new Cre_Apt_Efca_5(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + // Register to EVENT_FIRST_COMMAND_AFTER_SELECT + thisApplet.obReg.setEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + result = thisApplet.obReg.initMenuEntry(Menu1, (short) 0, (short) 5, (byte) 0, false, (byte) 0, (short) 0); + result = thisApplet.obReg.initMenuEntry(Menu2, (short) 0, (short) 5, (byte) 0, false, (byte) 0, (short) 0); + } + + + // Method called by the UICC CAT Runtime Environment + public void processToolkit(short event) { + + bRes=false; + testCaseNb=(byte)0x01; + if(event==EVENT_FIRST_COMMAND_AFTER_ATR) { + /* Test Case 1: The applet is triggered by EVENT_FIRST_COMMAND_AFTER_ATR + * Applet disables a menu entry + */ + try{ + //The Menu2 is disabled + obReg.disableMenuEntry(result); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + } else { + reportTestOutcome(testCaseNb,bRes); + } + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Test_Cre_Apt_Efca.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Test_Cre_Apt_Efca.java new file mode 100644 index 0000000000000000000000000000000000000000..e1f3f5c70c07cbb520d591d0ec9b7055f9344c80 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/Test_Cre_Apt_Efca.java @@ -0,0 +1,169 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_FIRST_COMMAND_AFTER_ATR +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_efca; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Efca extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_efca"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String CLASS_AID_4 = "A0000000 090005FF FFFFFF89 50040001"; + static final String CLASS_AID_5 = "A0000000 090005FF FFFFFF89 50050001"; + + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + static final String APPLET_AID_4 = "A0000000 090005FF FFFFFF89 50040102"; + static final String APPLET_AID_5 = "A0000000 090005FF FFFFFF89 50050102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Efca() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008"+ // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED BY EVENT_FIRST_COMMAND_AFTER_ATR, + //*** 2-APPLET 2 IS TRIGGERED BY EVENT_PROFILE_DONWLOAD + //*** 3_APPLET 3 IS NOT TRIGGERED + test.terminalProfileSession("09010020 01"); + + //***TEST CASE 1: 4-APPLET 3 IS TRIGGERED + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result = response.checkSw("9000"); + + test.reset(); + //***TEST CASE 2: 1-APPLET 3 IS TRIGGERED, APPLET 1, APPLET 2 ARE NOT TRIGGERED + test.terminalProfileSession("09010020 01"); + test.installApplet(CAP_FILE_PATH, CLASS_AID_4, APPLET_AID_4, + "8008"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level as Applet 3 + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + //***TEST CASE 3: 1-APPLET 4 IS TRIGGERED BY THE EVENT_FIRST_COMMAND_AFTER_ATR + //*** 2-APPLET 3 IS TRIGGERED BY THE EVENT_FIRST_COMMAND_AFTER_ATR + //*** 3-APPLET 4 IS TRIGGERED BY THE EVENT_PROFILE_DONWLOAD + //*** 4-APPLET 3 IS TRIGGERED BY THE EVENT_PROFILE_DONWLOAD + + test.terminalProfileSession("09010020 01"); + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10"+APPLET_AID_3+"05CCCCCC CCCC"); + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10"+APPLET_AID_4+"02CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deleteApplet(APPLET_AID_4); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + //TEST CASE 4: INSTALL APPLET 5 + test.installApplet(CAP_FILE_PATH, CLASS_AID_5, APPLET_AID_5, + "800C"+ // TLV UICC Toolkit application specific parameters + "04" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the second menu entry + "02" + // V Position of the second menu entry + "02" + // V Identifier of the second menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + //***TEST CASE 4: 1-APPLET 5 IS TRIGGERED BY THE EVENT_FIRST_COMMAND_AFTER_ATR + response = test.terminalProfile("09010020 01"); + result &= response.checkSw("911E"); + //***TEST CASE 4: 1-APPLET 5 DISABLES A MENU ENTRY, THE FETCH OF SET UP MENU CONTAIN ONLY ONE ITEM + response = test.fetch("1E"); + result &= response.checkData("D01C8103 01250082 02818285 09554943" + + "43205445 53548F06 014D656E 7531"); + + // check results + response = test.selectApplication(APPLET_AID_5); + result &= response.checkData("10"+APPLET_AID_5+"01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_5); + test.deletePackage(CAP_FILE_PATH); + + return result; + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c6322c7a6e37ab62eeb2ce4f571003ae0fbe64a0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/applet.opt @@ -0,0 +1,8 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x04:0x00:0x01 uicc.test.catre.cre_apt_efca.Cre_Apt_Efca_4 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_efca.Cre_Apt_Efca_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_apt_efca.Cre_Apt_Efca_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_efca.Cre_Apt_Efca_1 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x05:0x00:0x01 uicc.test.catre.cre_apt_efca.Cre_Apt_Efca_5 +uicc.test.catre.cre_apt_efca +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/javacard/cre_apt_efca.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/javacard/cre_apt_efca.cap new file mode 100644 index 0000000000000000000000000000000000000000..0692cad74f2a19b86721636ccaf5a5e649a413c1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_efca/javacard/cre_apt_efca.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Cre_Apt_Emse_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Cre_Apt_Emse_1.java new file mode 100644 index 0000000000000000000000000000000000000000..08faa19bee2964d186485c3c08124bcd8edc1fad --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Cre_Apt_Emse_1.java @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Emse_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_emse; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_MENU_SELECTION + * + * + * + * + * + */ + + public class Cre_Apt_Emse_1 extends TestToolkitApplet{ + + private static byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry1 ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + private static boolean bRes; + //private static ToolkitRegistry obReg; + + //Constructor of the applet + + public Cre_Apt_Emse_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Emse_1 thisApplet = new Cre_Apt_Emse_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry1,(short)0x00,(short)menuEntry1.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes= thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + + switch(testCaseNb){ + case (byte)0x00: + //TEST CASE 1: THE APPLET IS REGISTERED TO EVENT_MENU_SELECTION EVENT + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TESTCASE 2: THE APPLET IS TRIGGERED + bRes=false; + testCaseNb=(byte)0x02; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,bRes); + break; + + case (byte)0x02: + bRes=false; + testCaseNb=(byte)0x03; + reportTestOutcome(testCaseNb,bRes); + } + + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Cre_Apt_Emse_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Cre_Apt_Emse_2.java new file mode 100644 index 0000000000000000000000000000000000000000..41ef1165123d3685746e3d5d8110a4933cfcb080 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Cre_Apt_Emse_2.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Emse_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_emse; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_MENU_SELECTION + * + * + * + * + * + */ + + public class Cre_Apt_Emse_2 extends TestToolkitApplet{ + + private static byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry2 ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'2'}; + private static boolean bRes; + private byte nbTriggers=(byte)0x00; + + //Constructor of the applet + + public Cre_Apt_Emse_2(){ + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Emse_2 thisApplet = new Cre_Apt_Emse_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry2,(short)0x00,(short)menuEntry2.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION); + thisApplet.reportTestOutcome((byte)0x02,bRes); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + //TEST CASE 1: THE APPLET IS REGISTERED TO EVENT_MENU_SELECTION EVENT + nbTriggers++; + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + if(nbTriggers!=1){ + bRes=false; + testCaseNb=(byte)0x02; + reportTestOutcome(testCaseNb,bRes); + } + bRes=true; + testCaseNb=(byte)0x03; + reportTestOutcome(testCaseNb,bRes); + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Test_Cre_Apt_Emse.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Test_Cre_Apt_Emse.java new file mode 100644 index 0000000000000000000000000000000000000000..bf1cb9908ae303cc6a42c363c9cfa544c0281b89 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/Test_Cre_Apt_Emse.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_MENU_SELECTION +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_emse; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Emse extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_emse"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Emse() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Position of the first menu entry + "02" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + test.terminalProfileSession("09010020 01"); + //***TEST CASE 2: THE APPLET 1 MUST BE TRIGGERED *** + //***AND APPLET 2 IS NOT TRIGGERED**** + //ENVELOPE MENU SELECTION WITH IDENTIFIER=01 + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE1: APPLET2 IS TRIGGERED AND APPLET1 IS NOT TRIGGERED*** + //ENVELOPE MENU SELECTION WITH IDENTIFIER=02 + test.envelopeMenuSelection("100102", "");//Help Request not available + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"03CCCCCC"); + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..97035c5dbc888218f2b970c54c66f42e0b229e86 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_emse.Cre_Apt_Emse_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_emse.Cre_Apt_Emse_1 +uicc.test.catre.cre_apt_emse +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/javacard/cre_apt_emse.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/javacard/cre_apt_emse.cap new file mode 100644 index 0000000000000000000000000000000000000000..3f0d71194dfc2899b3149a1db010604768cf9dc0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emse/javacard/cre_apt_emse.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_1.java new file mode 100644 index 0000000000000000000000000000000000000000..cfe6748f51455d1d21ecff1b2cc424ba6d01ed7b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_1.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Emsh_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_emsh; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_MENU_SELECTION_HELP_REQUEST + * + * + * + * + */ + + public class Cre_Apt_Emsh_1 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry1A = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'1',(byte)'A'}; + private static byte[] menuEntry1B = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'1',(byte)'B'}; + private static boolean bRes; + + + // Constructor of the applet + public Cre_Apt_Emsh_1() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instace + Cre_Apt_Emsh_1 thisApplet = new Cre_Apt_Emsh_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + // register to EVENT_MENU_SELECTION_HELP_REQUEST + thisApplet.obReg.initMenuEntry(menuEntry1A,(short)0x00,(short)menuEntry1A.length,(byte)0x00,true,(byte)0x00,(short)0x00); + // register to EVENT_MENU_SELECTION (Help request is not supported) + thisApplet.obReg.initMenuEntry(menuEntry1B,(short)0x00,(short)menuEntry1B.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + // Test Case 1: Check if the applet is registered to the event + bRes=thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + } + + + // Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event) { + + if (event == EVENT_MENU_SELECTION_HELP_REQUEST) { + + switch(testCaseNb) { + case (byte)0x00: + // Test Case 1: 1-The applet is registered to EVENT_MENU_SELECTION_HELP_REQUEST + testCaseNb= (byte)0x01; + reportTestOutcome(testCaseNb,bRes); + // 3-The applet is triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier 01 + testCaseNb = (byte) 0x02; + bRes= true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x03; + // 4-The applet is not triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier 02 + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x04; + break; + case (byte)0x04: + // 4-The applet shall not triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier different from 01 + bRes= false; + testCaseNb = (byte) 0x03; + reportTestOutcome(testCaseNb,bRes); + break; + } + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_2.java new file mode 100644 index 0000000000000000000000000000000000000000..c7ccd4798f3fa75aaa1c6496269366cca19fa9e4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_2.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Emsh_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_emsh; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_MENU_SELECTION_HELP_REQUEST + * + * + * + */ + + public class Cre_Apt_Emsh_2 extends TestToolkitApplet { + + private static byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry2A ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'2',(byte)'A'}; + private static byte[] menuEntry2B ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'2',(byte)'B'}; + private static boolean bRes; + + // Constructor of the applet + public Cre_Apt_Emsh_2() { + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Apt_Emsh_2 thisApplet = new Cre_Apt_Emsh_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register to EVENT_MENU_SELECTION_HELP_REQUEST + thisApplet.obReg.initMenuEntry(menuEntry2A,(short)0x00,(short)menuEntry2A.length,(byte)0x00,true,(byte)0x00,(short)0x00); + thisApplet.obReg.initMenuEntry(menuEntry2B,(short)0x00,(short)menuEntry2B.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + // Test Case 2: Check if the applet is registered to the event + bRes=thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + } + + + // Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event) { + + if (event == EVENT_MENU_SELECTION_HELP_REQUEST) { + + switch(testCaseNb) { + case (byte)0x00: + // Test Case 1: 1-The applet is registered to EVENT_MENU_SELECTION_HELP_REQUEST + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + // 5-The applet is triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier 03 + testCaseNb = (byte) 0x02; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x03; + // 6-The applet is not triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier 04 + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x04; + break; + case (byte)0x04: + // 6-The applet shall not triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier different from 03 + bRes= false; + testCaseNb = (byte) 0x03; + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_3.java new file mode 100644 index 0000000000000000000000000000000000000000..ade15f37038f89fb45e1ef63a4757da29c293575 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Cre_Apt_Emsh_3.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Emsh_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_emsh; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_MENU_SELECTION_HELP_REQUEST + * + * + * + */ + + public class Cre_Apt_Emsh_3 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry3A = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'3',(byte)'A'}; + private static byte[] menuEntry3B = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'3',(byte)'B'}; + private static byte[] menuEntry3C = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'3',(byte)'C'}; + private static boolean bRes; + + + // Constructor of the applet + public Cre_Apt_Emsh_3() { + + + } + + + // Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instace + Cre_Apt_Emsh_3 thisApplet = new Cre_Apt_Emsh_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + // register to EVENT_MENU_SELECTION_HELP_REQUEST + thisApplet.obReg.initMenuEntry(menuEntry3A,(short)0x00,(short)menuEntry3A.length,(byte)0x00,true,(byte)0x00,(short)0x00); + thisApplet.obReg.initMenuEntry(menuEntry3B,(short)0x00,(short)menuEntry3B.length,(byte)0x00,true,(byte)0x00,(short)0x00); + thisApplet.obReg.initMenuEntry(menuEntry3C,(short)0x00,(short)menuEntry3C.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + // Test Case 1: Check if the applet is registered to the event + bRes=thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + } + + + // Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event) { + + if (event == EVENT_MENU_SELECTION_HELP_REQUEST) { + + switch(testCaseNb) { + case (byte)0x00: + // Test Case 2: 2-The applet is triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier 05 + testCaseNb= (byte)0x01; + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x02; + // 3-Call disableMenuEntry() method for Item Identifier 05 + try { + obReg.disableMenuEntry((byte)0x05); + bRes= true; + } + catch (ToolkitException e) { + bRes= false; + } + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x03; + break; + + case (byte)0x03: + // 4-The applet is triggered by EVENT_MENU_SELECTION_HELP_REQUEST with Item identifier 06 + bRes= true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb = (byte) 0x04; + // 5-Call disableMenuEntry() method for Item Identifier 06 + try { + obReg.disableMenuEntry((byte)0x06); + bRes= true; + } + catch (ToolkitException e) { + bRes= false; + } + reportTestOutcome(testCaseNb,bRes); + break; + } + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Test_Cre_Apt_Emsh.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Test_Cre_Apt_Emsh.java new file mode 100644 index 0000000000000000000000000000000000000000..44c123633ac3c2d2a5b6e8f18de0ab6024011fb0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/Test_Cre_Apt_Emsh.java @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_MENU_SELECTION_HELP_REQUEST +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_emsh; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Emsh extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_emsh"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Apt_Emsh() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0B" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "02" + // V Position of the second menu entry + "02" + // V Identifier of the second menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800C"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0B" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "03" + // V Position of the third menu entry + "03" + // V Identifier of the third menu entry + "04" + // V Position of the fourth menu entry + "04" + // V Identifier of the fourth menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + + // test script + test.reset(); + test.terminalProfileSession("09010020 01"); + //*** Test Case 1: 3-Applet1 is triggered, Applet2 is not triggered **** + test.envelopeMenuSelection("100101", "1500");//Help Request + //*** Test Case 1: 4-Applet1, Applet2 are not triggered **** + test.envelopeMenuSelection("100102", "1500");//Help Request + //*** Test Case 1: 5-Applet2 is triggered, Applet1 is not triggered **** + test.envelopeMenuSelection("100103", "1500");//Help Request + //*** Test Case 1: 6-Applet2, Applet1 are not triggered **** + test.envelopeMenuSelection("100104", "1500");//Help Request + // check results of Applet 1 and Applet2. + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"03CCCCCC"); + //Delete Applet 1 and Applet2. + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + //Install Applet 3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800E"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0B" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "05" + // V Position of the fifth menu entry + "05" + // V Identifier of the fifth menu entry + "06" + // V Position of the sixth menu entry + "06" + // V Identifier of the sixth menu entry + "07" + // V Position of the seventh menu entry + "07" + // V Identifier of the seventh menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.reset(); + test.terminalProfile("09010020 01"); + //UICC proactive command SET UP MENU, Menu Entry ID 05, 06, 07, Help Request supported + response = test.fetch("37"); + result &= response.checkData("D0358103 01258082 02818285 09554943" + + "43205445 53548F09 05417070 6C657433" + + "418F0906 4170706C 65743342 8F090741" + + "70706C65 743343"); + test.terminalResponse("81030125 80820282 81830100"); + //*** Test Case 2: 2-Applet3 is triggered **** + test.envelopeMenuSelection("100105", "1500");//Help Request + response = test.fetch("2C"); + result &= response.checkData("D02A8103 01258082 02818285 09554943" + + "43205445 53548F09 06417070 6C657433" + + "428F0907 4170706C 65743343"); + test.terminalResponse("81030125 80820282 81830100"); + //*** Test Case 2: 4-Applet3 is triggered **** + test.envelopeMenuSelection("100106", "1500");//Help Request + response = test.fetch("21"); + result &= response.checkData("D01F8103 01250082 02818285 09554943" + + "43205445 53548F09 07417070 6C657433" + + "43"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + + // check results + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10"+APPLET_AID_3+"04CCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c9bacd455875f1c316e6dd8f8cfd7fdf28c69ba0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_emsh.Cre_Apt_Emsh_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_apt_emsh.Cre_Apt_Emsh_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_emsh.Cre_Apt_Emsh_1 +uicc.test.catre.cre_apt_emsh +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/javacard/cre_apt_emsh.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/javacard/cre_apt_emsh.cap new file mode 100644 index 0000000000000000000000000000000000000000..49c2604f53f2a6966b43cadcc697dc9f3bd6d0a3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_emsh/javacard/cre_apt_emsh.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3109e564631f406b360afccdb66ed2b9e9782450 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_1.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Epdw_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_epdw; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_PROFILE_DOWNLOAD + * + * + * + * + * + */ + + public class Cre_Apt_Epdw_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private boolean bRes; + + + //Constructor of the applet + + public Cre_Apt_Epdw_1(){ + + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instance + Cre_Apt_Epdw_1 thisApplet = new Cre_Apt_Epdw_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT PROFILE DONWLOAD + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + if(event ==EVENT_PROFILE_DOWNLOAD){ + bRes=false; + switch(testCaseNb){ + + case (byte)0x00: + //TEST CASE 1: THE APPLET IS TRIGGERED + testCaseNb=(byte)0x01; + bRes=true; + //create the table of results + reportTestOutcome(testCaseNb,bRes); + break; + + case (byte)0x01: + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to the event EVENT_PROFILE_DOWNLOAD + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + //create the table of results + reportTestOutcome(testCaseNb,bRes); + //This case is only to store a 0xCC in the test case 3 + reportTestOutcome((byte)0x03,true); + + break; + case (byte)0x02: + //if the applet is triggered, wrongly, a 0x00 is stored in the test case 3 + testCaseNb=(byte)0x03; + //create the table of results + reportTestOutcome(testCaseNb,false); + } + } + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_2.java new file mode 100644 index 0000000000000000000000000000000000000000..29331f1365a234872c0fa3f0a7830cb0a4785429 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_2.java @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Epdw_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_epdw; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_PROFILE_DOWNLOAD + * + * + * + * + * + */ + + public class Cre_Apt_Epdw_2 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private boolean bRes; + + + //Constructor of the applet + + public Cre_Apt_Epdw_2(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Epdw_2 thisApplet = new Cre_Apt_Epdw_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT PROFILE DOWNLOAD + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + if(event==EVENT_PROFILE_DOWNLOAD){ + bRes=false; + switch(testCaseNb){ + + case (byte)0x00: + //TEST CASE 1: THE APPLET IS TRIGGERED + testCaseNb=(byte)0x01; + bRes=true; + //create the table of results + reportTestOutcome(testCaseNb,bRes); + break; + + case (byte)0x01: + + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + //create the table of results + reportTestOutcome(testCaseNb,bRes); + //This case is only to put 0xCC in the test case 3. + reportTestOutcome((byte)0x03,true); + + break; + + case (byte)0x02: + //if the applet is triggered, wrongly, then 0x00 is stored in the test case 3 + testCaseNb=(byte)0x03; + //create the table of results + reportTestOutcome(testCaseNb,false); + } + } + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_3.java new file mode 100644 index 0000000000000000000000000000000000000000..6e78467586f6f756649378f4b180dc052d37468c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Cre_Apt_Epdw_3.java @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Epdw_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_epdw; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_PROFILE_DOWNLOAD + * + * + * + * + * + */ + + public class Cre_Apt_Epdw_3 extends TestToolkitApplet{ + + private static byte testCaseNb = (byte) 0x00; + private static byte cntCases = (byte)0x00; + private byte[] TEXT= {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)' ',(byte)'1'}; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'3'}; + private boolean bRes; + + + //Constructor of the applet + + + public Cre_Apt_Epdw_3(){ + // + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Epdw_3 thisApplet = new Cre_Apt_Epdw_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + thisApplet.reportTestOutcome((byte)0x01,true); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + bRes=false; + switch(event){ + + //event EVENT_PROFILE_DOWNLOAD + case EVENT_PROFILE_DOWNLOAD: + + switch(cntCases){ + case (byte)0x00: + testCaseNb=(byte)0x01; + //create the table of results + reportTestOutcome(testCaseNb,bRes); + break; + + case (byte)0x01: + testCaseNb=(byte)0x03; + bRes=true; + //create the table of results + reportTestOutcome(testCaseNb,bRes); + } + break; + + case EVENT_MENU_SELECTION: + testCaseNb=(byte)0x02; + cntCases=(byte)0x01; + try{ + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + //build a Proactive Command Refresh + proHdlr.init(PRO_CMD_REFRESH,(byte)0x03,DEV_ID_TERMINAL); + //send the Refresh command + proHdlr.send(); + //register to EVENT_PROFILE_DOWNLOAD + obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + //create the table of results + reportTestOutcome(testCaseNb,bRes); + + } + + + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Test_Cre_Apt_Epdw.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Test_Cre_Apt_Epdw.java new file mode 100644 index 0000000000000000000000000000000000000000..e1a5e4b2151670e3543a24c2816b1b27e1d940a1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/Test_Cre_Apt_Epdw.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +// Package Definition +// UICC CAT Runtime Environment Applet Triggering +// EVENT_PROFILE_DOWNLOAD +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_epdw; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Epdw extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_epdw"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Epdw() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008"+ // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + //***TEST CASE 1 OF THE APPLETS 1 AND 2 *** + test.terminalProfileSession("09018000 01"); + //***TEST CASE 1 OF THE APPLET 3 *** + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result = response.checkSw("910B"); + response = test.fetch("0B"); + result &= response.checkData("D0098103 01010382 028182"); + + //***TEST CASE 2 OF THE APPLETS 1 AND 2 *** + test.terminalProfileSession("03010000 01"); + //TERMINAL RESPONSE TO THE REFRESH OF THE APPLET3 + test.terminalResponse("81030101 03820282 81030100"); + //***TEST CASE 3 OF THE APPLET 3 **** + test.terminalProfileSession("03010000 01"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10"+APPLET_AID_3+"03CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c604fa9c53a83c35165c65efd167e9bfd4ac54fc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_epdw.Cre_Apt_Epdw_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_apt_epdw.Cre_Apt_Epdw_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_epdw.Cre_Apt_Epdw_1 +uicc.test.catre.cre_apt_epdw +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/javacard/cre_apt_epdw.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/javacard/cre_apt_epdw.cap new file mode 100644 index 0000000000000000000000000000000000000000..502b1a5a530180a7c93e91d8b4be59b64b734dcd Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epdw/javacard/cre_apt_epdw.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Cre_Apt_Epha_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Cre_Apt_Epha_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e1bf2216d4747afe6e628589308d281a60f53bfc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Cre_Apt_Epha_1.java @@ -0,0 +1,170 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Epha_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_epha; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: CAT Runtime Environment Applet Triggering EVENT_PROACTIVE_HANDLER_AVAILABLE + * + * + * + * + * + */ + +public class Cre_Apt_Epha_1 extends TestToolkitApplet{ + private byte testCaseNb = (byte) 0x00; + private boolean bRes = false; + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'1'}; + private static byte[] menuEntry= {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'1'}; + + //Constructor of the applet + + public Cre_Apt_Epha_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Epha_1 thisApplet = new Cre_Apt_Epha_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + + if(event==EVENT_MENU_SELECTION ){ + switch(testCaseNb){ + //TestCase 1: 1- Applet1 is triggered + case (byte)0x00: + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 1.1- No exception is thrown + testCaseNb=(byte)0x02; + try{ + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 1.2- No exception is thrown + //TestCase 1: 1.3- Method returns TRUE + testCaseNb=(byte)0x03; + try{ + obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); //1.2 + bRes=obReg.isEventSet(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); //1.3 + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 1.4- Method returns TRUE + testCaseNb=(byte)0x04; + bRes=obReg.isEventSet(EVENT_PROACTIVE_HANDLER_AVAILABLE); + reportTestOutcome(testCaseNb,bRes); + break; + + //TestCase 2: 1- Applet1 is triggered + case (byte)0x0B: + testCaseNb=(byte)0x0C; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x0D; + try{ + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.initDisplayText((byte)0x80,(byte)0x04,TEXT,(short)0x00,(short)TEXT.length); + prHdlr.send(); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + break; + } + } + + if(event==EVENT_PROACTIVE_HANDLER_AVAILABLE){ + switch(testCaseNb){ + //TestCase 1: 2- Applet1 is triggered + case (byte)0x04: + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 3- Method returns FALSE + testCaseNb=(byte)0x06; + bRes=!obReg.isEventSet(EVENT_PROACTIVE_HANDLER_AVAILABLE); + reportTestOutcome(testCaseNb,bRes); + break; + + //TestCase 1: - Applet1 is triggered + case (byte)0x09: + testCaseNb=(byte)0x0A; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 9- Method returns FALSE + testCaseNb=(byte)0x0B; + bRes=!obReg.isEventSet(EVENT_PROACTIVE_HANDLER_AVAILABLE); + reportTestOutcome(testCaseNb,bRes); + break; + } + } + + if(event==EVENT_EVENT_DOWNLOAD_USER_ACTIVITY){ + switch(testCaseNb){ + //TestCase 1: 4- Applet1 is triggered + case (byte)0x06: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 5- No exception is thrown + try{ + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + testCaseNb=(byte)0x08; + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 6- Method returns TRUE + testCaseNb=(byte)0x09; + bRes=obReg.isEventSet(EVENT_PROACTIVE_HANDLER_AVAILABLE); + reportTestOutcome(testCaseNb,bRes); + + + break; + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Cre_Apt_Epha_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Cre_Apt_Epha_2.java new file mode 100644 index 0000000000000000000000000000000000000000..eceade9d09521b0b1be36230d2896b8867fca741 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Cre_Apt_Epha_2.java @@ -0,0 +1,128 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Epha_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_epha; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_PROACTIVE_HANDLER_AVAILABLE + * + * + * + * + * + */ + +public class Cre_Apt_Epha_2 extends TestToolkitApplet{ + private byte testCaseNb = (byte) 0x00; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)'2'}; + private boolean bRes=false; + + + //Constructor of the applet + + public Cre_Apt_Epha_2(){ + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Epha_2 thisApplet = new Cre_Apt_Epha_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + if(event==EVENT_EVENT_DOWNLOAD_USER_ACTIVITY){ + switch(testCaseNb){ + //TestCase 1: Applet2 is triggered + case (byte)0x00: + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + testCaseNb=(byte)0x02; + //TestCase 1: 7- No exception is thrown + try{ + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + //TestCase 1: 8- Method returns TRUE + testCaseNb=(byte)0x03; + bRes=obReg.isEventSet(EVENT_PROACTIVE_HANDLER_AVAILABLE); + reportTestOutcome(testCaseNb,bRes); + break; + } + } + + if(event==EVENT_MENU_SELECTION ){ + switch(testCaseNb){ + + case (byte)0x05: + testCaseNb=(byte)0x06; + try{ + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + break; + } + } + + if(event==EVENT_PROACTIVE_HANDLER_AVAILABLE){ + //TestCase 2:Applet must be triggered + switch(testCaseNb){ + //TestCase 1: 9- Applet1 is triggered + case (byte)0x03: + testCaseNb=(byte)0x04; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + //TestCase 1: 10- Method returns FALSE + testCaseNb=(byte)0x05; + bRes=!obReg.isEventSet(EVENT_PROACTIVE_HANDLER_AVAILABLE); + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x06: + testCaseNb=(byte)0x07; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Test_Cre_Apt_Epha.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Test_Cre_Apt_Epha.java new file mode 100644 index 0000000000000000000000000000000000000000..c97fdd00ee6907115f7f737a10a3db5ea66ce8ad --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/Test_Cre_Apt_Epha.java @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: CAT Runtime Environment Applet Triggering +// EVENT_PROACTIVE_HANDLER_AVAILABLE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_epha; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Epha extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_epha"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String Text1 = "54657874 31"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Epha() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A"+ // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Position of the first menu entry + "02" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + test.terminalProfileSession("09030100"); + //***TEST CASE 1: 1-APPLET 1 IS TRIGGERED*** + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result = response.checkSw("9000"); + //***TEST CASE 1: 4-APPLET 1 IS TRIGGERED*** + test.envelopeEventDownloadUserActivity(); + //***TEST CASE 2: 1-APPLET 1 IS TRIGGERED*** + response = test.envelopeMenuSelection("100101", "");//Help Request not available + result &= response.checkSw("9113"); + response = test.fetch("13"); + result &= response.checkData("D0118103 01218082 0281028D 0604"+Text1); + //***TEST CASE 2: 3-APPLET 2 IS TRIGGERED*** + test.envelopeMenuSelection("100102", "");//Help Request not available + test.reset(); + test.terminalProfileSession("09030100"); + + + + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"0CCCCCCC CCCCCCCC CCCCCCCC CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"07CCCCCC CCCCCCCC"); + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..aa7734208902b78e063f195a218837d8e95e5e49 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_epha.Cre_Apt_Epha_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_epha.Cre_Apt_Epha_1 +uicc.test.catre.cre_apt_epha +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/javacard/cre_apt_epha.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/javacard/cre_apt_epha.cap new file mode 100644 index 0000000000000000000000000000000000000000..6900517eb5689ebd6797f5651bfafdce5711bffc Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_epha/javacard/cre_apt_epha.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_1.java new file mode 100644 index 0000000000000000000000000000000000000000..015f34da1ee4d17bf986d67f7ee8d9486d5c4bee --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_1.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Estc_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_estc; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_STATUS_COMMAND + * + * + * + * + * + */ + +public class Cre_Apt_Estc_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private boolean bRes; + + //Constructor of the applet + + public Cre_Apt_Estc_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Estc_1 thisApplet = new Cre_Apt_Estc_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT STATUS COMMAND + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + bRes=false; + //event STATUS_COMMAND + switch(testCaseNb){ + + case (byte)0x00: + //TEST CASE 1: THE APPLET IS TRIGGERED + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + + case (byte)0x01: + //TEST CASE 2 : THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to STATUS_COMMAND + obReg.requestPollInterval(POLL_NO_DURATION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + //if the applet is triggered the a 0x00 is stored in the test case 3 + testCaseNb=(byte)0x03; + reportTestOutcome(testCaseNb,false); + + } + + } + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_2.java new file mode 100644 index 0000000000000000000000000000000000000000..cea2cec6f4523eb148e83a02b4dcb734b2d2941d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_2.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Estc_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_estc; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_STATUS_COMMAND + * + * Applet is triggered on Install (Install, all events + * + * @version 0.0.1 - 03/08/04 + * + */ + + public class Cre_Apt_Estc_2 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private boolean bRes; + + //Constructor of the applet + + public Cre_Apt_Estc_2(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Estc_2 thisApplet = new Cre_Apt_Estc_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT STATUS COMMAND + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + bRes=false; + //event STATUS_COMMAND + switch(testCaseNb){ + + case (byte)0x00: + //TEST CASE 1: THE APPLET IS TRIGGERED + testCaseNb=(byte)0x01; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + break; + + case (byte)0x01: + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to STATUS_COMMAND + obReg.requestPollInterval(POLL_NO_DURATION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + //if the applet is triggered then 0x00 is stored in the test case 3 + testCaseNb=(byte)0x03; + reportTestOutcome(testCaseNb,false); + } + + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_3.java new file mode 100644 index 0000000000000000000000000000000000000000..e2051d44e9d3702d7515a524c13590db9ab12476 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Cre_Apt_Estc_3.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Estc_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_estc; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_STATUS_COMMAND + * + * Applet is triggered on Install (Install, all events + * + * @version 0.0.1 - 03/08/04 + * + */ + + public class Cre_Apt_Estc_3 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)' ',(byte)'1'}; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + private static byte cntCases = (byte)0x00; + private boolean bRes; + + + //Constructor of the applet + + public Cre_Apt_Estc_3(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Estc_3 thisApplet = new Cre_Apt_Estc_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + thisApplet.reportTestOutcome((byte)0x01,true); + } + + + //Method called by the UICC CAT Runtime Environment + + public void processToolkit(short event){ + bRes=false; + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 1: A DISPLAY TEXT IS SENT AND THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + cntCases=(byte)0x01; + try{ + //get the Proactive Handler + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + //build the proactive Command Display Text + proHdlr.initDisplayText((byte)0x80,(byte)0x04,TEXT,(short)0x00,(short)TEXT.length); + //send the command + proHdlr.send(); + //register to STATUS_COMMAND + obReg.requestPollInterval(POLL_SYSTEM_DURATION); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + } + //event STATUS_COMMAND + if(event==EVENT_STATUS_COMMAND) + { + switch(cntCases){ + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x01: + testCaseNb=(byte)0x03; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + + } + + } + + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Test_Cre_Apt_Estc.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Test_Cre_Apt_Estc.java new file mode 100644 index 0000000000000000000000000000000000000000..13c3c8c45bcaea315cfcf56e686e1dddf02e74ec --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/Test_Cre_Apt_Estc.java @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_STATUS_COMMAND +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_estc; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Estc extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_estc"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Estc() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008"+ // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A"+ // TLV UICC Toolkit application specific parameters + "03" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + //***TEST CASE 1: APPLET1, APPLET2 ARE TRIGGERED*** + test.terminalProfileSession("09016100 01"); + test.status("00", "0C", "00");//No data requested + //***TEST CASE 2: 1-APPLET3 IS TRIGGERED*** + response = test.envelopeMenuSelection("100101", "");//Help Request not available + //DISPLAY TEXT BY APPLET3 + result = response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045465" + + "78742031"); + //***TEST CASE 2: 3-APPLET1,APPLET2 ARE TRIGGERED*** + test.status("00", "0C", "00"); //No data requested + //TERMINAL RESPONSE TO THE DISPLAY TEXT OF THE APPLET3 + test.terminalResponse("81030121 80820282 81030100"); + //***TEST CASE 3 OF THE APPLET 3 **** + test.status("00", "0C", "00"); //No data requested + + + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10"+APPLET_AID_2+"03CCCCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10"+APPLET_AID_3+"03CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..f1d42ce94695b14049724e11891ad0324839a8a7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_apt_estc.Cre_Apt_Estc_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_apt_estc.Cre_Apt_Estc_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_estc.Cre_Apt_Estc_1 +uicc.test.catre.cre_apt_estc +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/javacard/cre_apt_estc.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/javacard/cre_apt_estc.cap new file mode 100644 index 0000000000000000000000000000000000000000..65a46910a22adb4b5d5705f24f8a715e85c73af0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_estc/javacard/cre_apt_estc.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/Cre_Apt_Etex_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/Cre_Apt_Etex_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e7205ceecb5b8280250461838920ce24a423897f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/Cre_Apt_Etex_1.java @@ -0,0 +1,139 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Etex_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_etex; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_TIMER_EXPIRATION + * + * + * + * + * + */ + + public class Cre_Apt_Etex_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte a; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + //Constructor of the applet + + public Cre_Apt_Etex_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Etex_1 thisApplet = new Cre_Apt_Etex_1(); + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + //register to EVENT TIMER EXPIRATION + try{ + + for(a=0; a<(byte)8; a++){ + thisApplet.obReg.allocateTimer(); + } + for(a=2; a<(byte)9; a++){ + thisApplet.obReg.releaseTimer((byte)a); + } + } + catch(Exception e){ + } + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + //Checks if the applet is registered to the event + bRes=thisApplet.obReg.isEventSet(EVENT_TIMER_EXPIRATION); + + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + + if(event==EVENT_TIMER_EXPIRATION){ + + switch(testCaseNb){ + + case (byte)0x00: + //TEST CASE 1: Store the result of the test if the applet is registered to the event + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + bRes=false; + //TEST CASE 2: The applet has been triggered and it's deregistered to the event + testCaseNb=(byte)0x02; + try{ + obReg.releaseTimer((byte)0x01); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + //TEST CASE 3: The applet must not be triggered in this case + //if the applet is triggered then the test is failed + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 5: The applet is triggered after the registration to the event + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 4: The applet is registered to the Timer Expiration event + testCaseNb=(byte)0x04; + try{ + for(a=0; a<(byte)8; a++){ + obReg.allocateTimer(); + } + for(a=2; a<(byte)9; a++){ + obReg.releaseTimer((byte)a); + } + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/Test_Cre_Apt_Etex.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/Test_Cre_Apt_Etex.java new file mode 100644 index 0000000000000000000000000000000000000000..496182cd68d5bd7bc996f8e52e54a8c4c3fecc86 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/Test_Cre_Apt_Etex.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_TIMER_EXPIRATION +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_etex; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Etex extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_etex"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Etex() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("29010000 01"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_TIMER_EXPIRATION*** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.envelopeTimerExpiration("240101"); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.envelopeTimerExpiration("240101"); + //***TEST CASE 2: 1 IS REGISTERED TO EVENT_TIMER_EXPIRATION*** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.envelopeTimerExpiration("240101"); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5cbc617d906263eac6fff1c1654b788f5c81af06 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_etex.Cre_Apt_Etex_1 +uicc.test.catre.cre_apt_etex +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/javacard/cre_apt_etex.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/javacard/cre_apt_etex.cap new file mode 100644 index 0000000000000000000000000000000000000000..6b7abaf488bde8d16638a4b7f5cb8456da5d1a6a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_etex/javacard/cre_apt_etex.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/Cre_Apt_Euev_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/Cre_Apt_Euev_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6f603060fdb1168d887337d60816ff38458d9562 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/Cre_Apt_Euev_1.java @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Euev_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_euev; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering EVENT_UNRECOGNIZED_ENVELOPE + * + * + * + * + * + */ +public class Cre_Apt_Euev_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] menuEntry ={(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e',(byte)'t',(byte)' ',(byte)'1'}; + + + + //Constructor of the applet + + public Cre_Apt_Euev_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Euev_1 thisApplet = new Cre_Apt_Euev_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to the UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT MENU SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0x00,(short)menuEntry.length,(byte)0x00,false,(byte)0x00,(short)0x00); + + bRes=thisApplet.obReg.isEventSet(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + + if(event==EVENT_UNRECOGNIZED_ENVELOPE){ + + switch(testCaseNb){ + + case (byte)0x00: + testCaseNb=(byte)0x01; + reportTestOutcome(testCaseNb,bRes); + //TEST CASE 2: THE APPLET IS UNREGISTERED TO THE EVENT + testCaseNb=(byte)0x02; + try{ + //deregister to the EVENT_UNRECOGNIZED_ENVELOPE event + obReg.clearEvent(EVENT_UNRECOGNIZED_ENVELOPE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + reportTestOutcome((byte)0x03,true); + break; + case (byte)0x02: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + break; + case (byte)0x04: + //TEST CASE 4: THE APPLET IS TRIGGERED + testCaseNb=(byte)0x05; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + } + } + + //event EVENT_MENU_SELECTION + if(event==EVENT_MENU_SELECTION){ + //TEST CASE 3:THE APPLET IS REGISTERED TO THE EVENT + testCaseNb=(byte)0x04; + try{ + //register to the EVENT_UNRECOGNIZED_ENVELOPE + obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + bRes=true; + } + catch(Exception e){ + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + + } + + } + + } \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/Test_Cre_Apt_Euev.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/Test_Cre_Apt_Euev.java new file mode 100644 index 0000000000000000000000000000000000000000..c767791799fe8fa2e160626d76b74a25add2a6dd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/Test_Cre_Apt_Euev.java @@ -0,0 +1,79 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// EVENT_UNRECOGNIZED_ENVELOPE +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_euev; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Euev extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_euev"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Euev() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of the first menu entry + "01" + // V Identifier of the first menu entry + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("FFFFFFFF FFFFFFFF FFFFFFFF"); + //***TEST CASE 1: 1-APPLET 1 IS REGISTERED TO EVENT_UNRECOGNIZED_ENVELOPE *** + //***TEST CASE 1: 2-APPLET 1 IS TRIGGERED*** + test.unrecognizedEnvelope(); + //***TEST CASE 2: 1-APPLET 1 IS NOT TRIGGERED*** + test.unrecognizedEnvelope(); + //***TEST CASE 2: 1 APPLET 1 IS REGISTERED TO EVENT_UNRECOGNIZED_ENVELOPE *** + test.envelopeMenuSelection("100101", "");//Help Request not available + //***TEST CASE 2: 2-APPLET 1 IS TRIGGERED*** + test.unrecognizedEnvelope(); + + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..77eb50cdbc9793dbb3620498d369df412c262257 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_euev.Cre_Apt_Euev_1 +uicc.test.catre.cre_apt_euev +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/javacard/cre_apt_euev.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/javacard/cre_apt_euev.cap new file mode 100644 index 0000000000000000000000000000000000000000..78537e5928abff6200d47411f70a97d92cdc44e5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_euev/javacard/cre_apt_euev.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/Cre_Apt_Genb_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/Cre_Apt_Genb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..43a3f8638507dc58df76f471ade572a63c313ce8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/Cre_Apt_Genb_1.java @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------- +// Cre_Apt_Genb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_apt_genb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * Test Area: UICC CAT Runtime Environment Applet Triggering General behaviour + * + * + * + * + * + */ +public class Cre_Apt_Genb_1 extends TestToolkitApplet{ + + private byte testCaseNb = (byte) 0x00; + private static byte nIndex = (byte) 0x00; + private static boolean bRes; + private static boolean bRes1=true; + + //Constructor of the applet + + public Cre_Apt_Genb_1(){ + + } + + + //Method called by the JCRE at the installation of the applet + public static void install (byte bArray[], short bOffset, byte bLength){ + + //Create a new applet instace + Cre_Apt_Genb_1 thisApplet = new Cre_Apt_Genb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + // Initialise the data of the test applet + thisApplet.init(); + //register to the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + bRes=true; + + nIndex=(byte)0x01; + } + + + //Method called by the UICC Toolkit Framework + + public void processToolkit(short event){ + + + if(event==EVENT_EVENT_DOWNLOAD_USER_ACTIVITY){ + switch (nIndex){ + + case(byte)0x01: + nIndex=(byte)0x01; + bRes1=false; + break; + + case(byte)0x02: + testCaseNb=(byte)0x02; + bRes=true; + reportTestOutcome(testCaseNb,bRes); + nIndex=(byte)0x03; + testCaseNb=(byte)0x03; + reportTestOutcome(testCaseNb,bRes); + break; + + case(byte)0x03: + testCaseNb=(byte)0x03; + bRes=false; + reportTestOutcome(testCaseNb,bRes); + nIndex=(byte)0x03; + break; + + case(byte)0x04: + testCaseNb=(byte)0x04; + bRes=true; + nIndex=(byte)0x04; + reportTestOutcome((byte)0x01,bRes1); + reportTestOutcome(testCaseNb,bRes); + break; + + } + } + } + + public void process(APDU apdu) { + if (selectingApplet()) { + /* update the counter */ + super.process(apdu); + nIndex++; + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/Test_Cre_Apt_Genb.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/Test_Cre_Apt_Genb.java new file mode 100644 index 0000000000000000000000000000000000000000..54074130bbeab8b9a679d733476f4686541a9350 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/Test_Cre_Apt_Genb.java @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// Package Definition +// Test Area: UICC CAT Runtime Environment Applet Triggering +// General behaviuour +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_apt_genb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Cre_Apt_Genb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_apt_genb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Cre_Apt_Genb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result; + + // start test + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + + //***TEST CASE 1: 2-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_USER_ACTIVITY *** + //***THE APPLET ISN'T IN SELECTABLE STATE: APPLET ISN'T TRIGGERED + response = test.installInstallApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + + "8008"+ // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + result = response.checkSw("9000"); + + // test script + test.reset(); + test.terminalProfileSession("01010000 20"); + + response = test.selectApplication(APPLET_AID_1); + result &= !response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("01010000 20"); + + response = test.envelopeEventDownloadUserActivity(); + + + //***TEST CASE 2: 2-APPLET IS IN SELECTABLE STATE:APPLET IS TRIGGERED *** + //*** + //**** INSTALL THE APPLET IN SELECTABLE STATE + response = test.makeSelectableApplet(APPLET_AID_1); + result &= response.checkSw("9000"); + response = test.selectApplication(APPLET_AID_1); + result &= response.checkSw("9000"); + + // test script + test.reset(); + test.terminalProfileSession("01010000 20"); + + response = test.envelopeEventDownloadUserActivity(); + + //***TEST CASE 3: 2-THE APPLET IS IN LOCK STATE: APPLET ISN'T TRIGGERED *** + response = test.lockApplication(APPLET_AID_1); + result &= response.checkSw("9000"); + response = test.selectApplication(APPLET_AID_1); + + result &= !response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("01010000 20"); + + response = test.envelopeEventDownloadUserActivity(); + + //***TEST CASE 4: 2-APPLET 1 IS REGISTERED TO EVENT_EVENT_DOWNLOAD_USER_ACTIVITY *** + //***APPLET IS IN UNLOCK STATE:APPLET IS TRIGGERED + + response = test.unlockApplication(APPLET_AID_1); + result &= response.checkSw("9000"); + response = test.selectApplication(APPLET_AID_1); + result &= response.checkSw("9000"); + + // test script + test.reset(); + test.terminalProfileSession("01010000 20"); + + response = test.envelopeEventDownloadUserActivity(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10"+APPLET_AID_1+"04CCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7b4801bbd56c6a774c3d30564dc6e62ebd34c3b9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_apt_genb.Cre_Apt_Genb_1 +uicc.test.catre.cre_apt_genb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/javacard/cre_apt_genb.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/javacard/cre_apt_genb.cap new file mode 100644 index 0000000000000000000000000000000000000000..89c50ab1703ac40a6577470bda0fb9f82e1e13af Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_apt_genb/javacard/cre_apt_genb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_1.java new file mode 100644 index 0000000000000000000000000000000000000000..903a6cd5eed7f578d5e4d64f4c9a7d91e5dfa6f3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_1.java @@ -0,0 +1,88 @@ +//----------------------------------------------------------------------------- +// FWK_ERP_ECCN_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_erp_eccn; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.test.util.*; + +/** + * Test Area : uicc.toolkitframework + * + * Chapter: Envelope Response Posting + * Test Area inside the chapter: EVENT_CALL_CONTROL_BY_NAA + * + * + * @version 0.0.1 - 11/12/01 + * @author 3GPP T3 SWG API + * + */ +public class Cre_Erp_Eccn_1 extends TestToolkitApplet +{ + private static final byte[] DATA2POST = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + + + // byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Cre_Erp_Eccn_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Erp_Eccn_1 thisApplet = new Cre_Erp_Eccn_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Triggering on EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + // Result of each test + boolean bRes = false; + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler envRespHandler = EnvelopeResponseHandlerSystem.getTheHandler(); + + // EVENT_CALL_CONTROL_BY_NAA : + // -------------------------------------------- + // The applet changes any incoming dialling number into + 11 22 33 44 + try { + bRes = false; + envRespHandler.appendTLV((byte)(TAG_ADDRESS | TAG_SET_CR), DATA2POST, (short)0x00, (short)DATA2POST.length); + envRespHandler.postAsBERTLV(true, (byte)0x02); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte)1, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_2.java new file mode 100644 index 0000000000000000000000000000000000000000..8003a365083810016a93789a764d3e3f2504f5d7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_2.java @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// Cre_Erp_Eccn_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_erp_eccn; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.test.util.*; + +/** + * Test Area : uicc.toolkitframework + * + * Chapter: Envelope Response Posting + * Test Area inside the chapter: EVENT_CALL_CONTROL_BY_NAA + * + * + * @version 0.0.1 - 11/12/01 + * @author 3GPP T3 SWG API + * + */ +public class Cre_Erp_Eccn_2 extends TestToolkitApplet +{ + private static final byte[] BUFFER = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T'} ; + private static final byte WAIT_FOR_USER_TO_CLEAR_MESSAGE = (byte)0x80; + private static final byte NEXT_ACTION_INDICATOR = (byte)0x00; + private static final short BEGINNING_OF_STRING = (short)0x00; + private static byte [] MenuEntry = {(byte) 'T', (byte) 'o', (byte) 'o', (byte) 'l', (byte) 'k', (byte) 'i', (byte) 't', (byte) 'T', (byte) 'e', (byte) 's', (byte) 't'}; + + + + //byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Cre_Erp_Eccn_2() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Erp_Eccn_2 thisApplet = new Cre_Erp_Eccn_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Triggering on EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuEntry, BEGINNING_OF_STRING, (short)MenuEntry.length, NEXT_ACTION_INDICATOR, false, (byte)0, (short)0); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + // Result of each test + boolean bRes = false; + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // EVENT_MENU_SELECTION : + // -------------------------------------------- + // The applet prepares and send a Display Text Proactive command with the string "APPLET" + try { + bRes = false; + proHdlr.initDisplayText(WAIT_FOR_USER_TO_CLEAR_MESSAGE, (byte)0x04 /*DCS_8_BIT_DATA*/, BUFFER, BEGINNING_OF_STRING, (short)BUFFER.length) ; + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte)1, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_3.java new file mode 100644 index 0000000000000000000000000000000000000000..5ecb03f1d39fc03da7709337611a41e1bd978b28 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Cre_Erp_Eccn_3.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +// Cre_Erp_Eccn_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_erp_eccn; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.test.util.*; + +/** + * Test Area : uicc.toolkitframework + * + * Chapter: Envelope Response Posting + * Test Area inside the chapter: EVENT_CALL_CONTROL_BY_NAA + * + * + * @version 0.0.1 - 11/12/01 + * @author 3GPP T3 SWG API + * + */ +public class Cre_Erp_Eccn_3 extends TestToolkitApplet +{ + private static final byte[] BUFFER = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T'} ; + private static final byte WAIT_FOR_USER_TO_CLEAR_MESSAGE = (byte)0x80; + private static final byte NEXT_ACTION_INDICATOR = (byte)0x00; + private static final short BEGINNING_OF_STRING = (short)0x00; + private static final byte[] DATA2POST = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + private static byte [] MenuEntry = {(byte) 'T', (byte) 'o', (byte) 'o', (byte) 'l', (byte) 'k', (byte) 'i', (byte) 't', (byte) 'T', (byte) 'e', (byte) 's', (byte) 't'}; + + + /** + * Constructor of the applet + */ + public Cre_Erp_Eccn_3() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Erp_Eccn_3 thisApplet = new Cre_Erp_Eccn_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Triggering on EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + // Triggering on EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuEntry, BEGINNING_OF_STRING, (short)MenuEntry.length, NEXT_ACTION_INDICATOR, false, (byte)0, (short)0); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of each test + boolean bRes = false; + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( event ) + { + case EVENT_MENU_SELECTION : + // -------------------------------------------- + // The applet prepares and send a Display Text Proactive command with the string "APPLET" + try { + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + bRes = false; + proHdlr.initDisplayText(WAIT_FOR_USER_TO_CLEAR_MESSAGE, (byte)0x04 /*DCS_8_BIT_DATA*/, BUFFER, BEGINNING_OF_STRING, (short)BUFFER.length) ; + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte)1, bRes); + break; + + case EVENT_CALL_CONTROL_BY_NAA : + // -------------------------------------------- + // The applet changes any incoming dialling number into + 11 22 33 44 + EnvelopeResponseHandler envRespHandler = EnvelopeResponseHandlerSystem.getTheHandler(); + envRespHandler.appendTLV((byte)(TAG_ADDRESS | TAG_SET_CR), DATA2POST, (short)0x00, (short)DATA2POST.length); + envRespHandler.postAsBERTLV(true, (byte)0x02); + + break; + + + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Test_Cre_Erp_Eccn.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Test_Cre_Erp_Eccn.java new file mode 100644 index 0000000000000000000000000000000000000000..84f6ca43392a969e27685707e64db10fd79be59c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/Test_Cre_Erp_Eccn.java @@ -0,0 +1,181 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_erp_eccn; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Erp_Eccn extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_erp_eccn"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Erp_Eccn() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet2 + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9114"); + + // Trigger Applet1 + response = test.envelopeCallControlByNAA(); + result &= response.checkData("02078605 91112233 44"); + result &= response.checkSw("9114"); + + // Fetch Display Text and Terminal Response + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07044150" + + "504C4554"); + response = test.terminalResponse("81030121 80820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applets */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete Applet1 and Applet2 + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + + // Install Applet3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + // Profile download + test.terminalProfileSession("09030120"); + + // Trigger Applet3 + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9114"); + + // Trigger Applet3 + response = test.envelopeCallControlByNAA(); + result &= response.checkData("02078605 91112233 44"); + result &= response.checkSw("9114"); + + // Fetch Display Text and Terminal Response + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07044150" + + "504C4554"); + response = test.terminalResponse("81030121 80820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete applets and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4f5e85243a8e5c444a9dfa38096e59eadf7eb92d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_erp_eccn.Cre_Erp_Eccn_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_erp_eccn.Cre_Erp_Eccn_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_erp_eccn.Cre_Erp_Eccn_1 +uicc.test.catre.cre_erp_eccn +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/javacard/cre_erp_eccn.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/javacard/cre_erp_eccn.cap new file mode 100644 index 0000000000000000000000000000000000000000..f31288b0b041e044e70532b30aa41857a83fedf7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_eccn/javacard/cre_erp_eccn.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/Cre_Erp_Euen_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/Cre_Erp_Euen_1.java new file mode 100644 index 0000000000000000000000000000000000000000..eba15a02d26afd86fc1b62c773ae3112dede0c8a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/Cre_Erp_Euen_1.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// Cre_Erp_Euen_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_erp_euen; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.test.util.* ; + + +public class Cre_Erp_Euen_1 extends TestToolkitApplet +{ + private static final short BEGINNING_OF_STRING = (short)0x00; + private static final byte[] DATA2POST = {(byte)0x0C, (byte)0xAB} ; + byte testCaseNb = (byte) 0x00; + byte[] buffer = new byte[25]; + + /** + * Constructor of the applet + */ + public Cre_Erp_Euen_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Erp_Euen_1 thisApplet = new Cre_Erp_Euen_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Triggering on EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false; + + // Sets the test case number + testCaseNb++; + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler envRespHandler = EnvelopeResponseHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 1 : + // -------------------------------------------- + // The UICC shall post the data issued by the applet + try { + bRes = false; + envRespHandler.appendArray(DATA2POST, (short)0x00, (short)DATA2POST.length); + envRespHandler.post(true); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte) 2 : + // -------------------------------------------- + // The UICC shall post the data issued by the applet + try { + bRes = false; + envRespHandler.appendArray(DATA2POST, (short)0x00, (short)DATA2POST.length); + envRespHandler.post(true); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/Test_Cre_Erp_Euen.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/Test_Cre_Erp_Euen.java new file mode 100644 index 0000000000000000000000000000000000000000..54554549a69141290b138d20665beeecc6504f28 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/Test_Cre_Erp_Euen.java @@ -0,0 +1,97 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_erp_euen; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Erp_Euen extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_erp_euen"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Erp_Euen() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Trigger Applet1 + response = test.unrecognizedEnvelope(); + result = response.checkData("0CAB"); + result &= response.checkSw("9000"); + + // Trigger Applet1 + response = test.unrecognizedEnvelope(); + result &= response.checkData("0CAB"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "02" + "CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6f8b0455ecc95a0c013c8a84edcb429fd1aebb78 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_erp_euen.Cre_Erp_Euen_1 +uicc.test.catre.cre_erp_euen +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/javacard/cre_erp_euen.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/javacard/cre_erp_euen.cap new file mode 100644 index 0000000000000000000000000000000000000000..d8417d7e93c8fd09a34219a27074e62e0bbd4ec0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_erp_euen/javacard/cre_erp_euen.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Cre_Exh_Genb_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Cre_Exh_Genb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a6567b7e9af92bd315a331ee510314dfdb3a248c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Cre_Exh_Genb_1.java @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_exh_genb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.* ; + + +public class Cre_Exh_Genb_1 extends TestToolkitApplet { + + + private static byte[] Menu = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private byte nbCase = 0; + + /** + * The Constructor registers the application for the Event. + */ + + private Cre_Exh_Genb_1() { + // Applet initialisation + nbCase = 0; + } + + + /** + * This method will be used to install the Applet. + */ + + public static void install(byte[] bArray, short bOffset, byte bLength) { + Cre_Exh_Genb_1 thisApplet = new Cre_Exh_Genb_1(); + + // Register the applet with the JCRE. + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(Menu, (short) 0, (short)Menu.length, (byte) 0, false, (byte) 0, (short) 0); + //register to EVENT_EVENT_DOWNLOAD_MT_CALL + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + } + + + /** + * This method will be used to trigger the tests. + * The application will be triggered by an Formatted SMS PP download event. + * @param event + */ + + public void processToolkit (short event) throws ToolkitException { + + boolean bRes = false; + + if (event == EVENT_EVENT_DOWNLOAD_MT_CALL) { + switch (nbCase) + { + case 0: + { + nbCase = 1; + ISOException busyException = new ISOException((short)0x9300); + bRes = true; + reportTestOutcome(nbCase, bRes); + throw (busyException); + } + + case 1: + { + nbCase = 2; + bRes = true; + reportTestOutcome(nbCase, bRes); + } + } + } + + if (event == EVENT_MENU_SELECTION) { + switch (nbCase) + { + case 2: + { + nbCase = 3; + ISOException busyException = new ISOException((short)0x9300); + bRes = true; + reportTestOutcome(nbCase, bRes); + throw (busyException); + } + + case 3: + { + nbCase = 4; + ISOException notBusyException = new ISOException((short)0x6F00); + bRes = true; + reportTestOutcome(nbCase, bRes); + throw (notBusyException); + } + + case 4: + { + nbCase = 5; + bRes = true; + reportTestOutcome(nbCase, bRes); + throw (new ToolkitException(ToolkitException.REGISTRY_ERROR)); + } + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Cre_Exh_Genb_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Cre_Exh_Genb_2.java new file mode 100644 index 0000000000000000000000000000000000000000..363af20d3a52bd552da151ed18364b8d4b45a731 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Cre_Exh_Genb_2.java @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_exh_genb; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.* ; + + + +public class Cre_Exh_Genb_2 extends TestToolkitApplet { + + private byte nbCase = 0; + + /** + * The Constructor registers the application for the Event. + */ + + private Cre_Exh_Genb_2() { + // Applet initialisation + nbCase = 0; + } + + + /** + * This method will be used to install the Applet. + */ + + public static void install(byte[] bArray, short bOffset, byte bLength) { + Cre_Exh_Genb_2 thisApplet = new Cre_Exh_Genb_2(); + + // Register the applet with the JCRE. + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + //register to EVENT_EVENT_DOWNLOAD_MT_CALL + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + //register to EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * This method will be used to trigger the tests. + * The application will be triggered by an Formatted SMS PP download event. + * @param event + */ + + public void processToolkit (short event) throws ToolkitException { + boolean bRes = false; + + if (event == EVENT_EVENT_DOWNLOAD_MT_CALL) { + switch (nbCase) + { + case 0: + { + nbCase = 1; + bRes = true; + reportTestOutcome(nbCase, bRes); + break; + } + case 1: + { + nbCase = 2; + ISOException busyException = new ISOException((short)0x9300); + bRes = true; + reportTestOutcome(nbCase, bRes); + throw (busyException); + } + } + } + + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + nbCase = 3; + ISOException busyException = new ISOException((short)0x9300); + bRes = true; + reportTestOutcome(nbCase, bRes); + throw (busyException); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Test_Cre_Exh_Genb.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Test_Cre_Exh_Genb.java new file mode 100644 index 0000000000000000000000000000000000000000..e7c961d473e0673396eb7deb2dfd00412112b667 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/Test_Cre_Exh_Genb.java @@ -0,0 +1,137 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_exh_genb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Exh_Genb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_exh_genb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Exh_Genb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession("09010020 FFFF"); + + // Trigger applets + response = test.envelopeEventDownloadMTCall(); + result = response.checkSw("9000"); + + // Trigger applets + response = test.envelopeEventDownloadMTCall(); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9300"); + + // Trigger Applet2 + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9300"); + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05" + "CCCCCCCC CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "03" + "CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9b85c8065789dcf194e3e9b3677c590cb87a1973 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_exh_genb.Cre_Exh_Genb_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_exh_genb.Cre_Exh_Genb_1 +uicc.test.catre.cre_exh_genb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/javacard/cre_exh_genb.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/javacard/cre_exh_genb.cap new file mode 100644 index 0000000000000000000000000000000000000000..acd9797311fd399f0614e10b59fca7a32802025a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_genb/javacard/cre_exh_genb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Cre_Exh_Imtg_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Cre_Exh_Imtg_1.java new file mode 100644 index 0000000000000000000000000000000000000000..21b8a1ff215c62e058a5c8353002b6ccf1f4e8e2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Cre_Exh_Imtg_1.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_exh_imtg; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + +import uicc.toolkit.*; +import uicc.test.util.* ; + + +public class Cre_Exh_Imtg_1 extends TestToolkitApplet { + + + /** + * The Constructor registers the application for the Event. + */ + + private Cre_Exh_Imtg_1() { + } + + + /** + * This method will be used to install the Applet. + */ + + public static void install(byte[] bArray, short bOffset, byte bLength) { + Cre_Exh_Imtg_1 thisApplet = new Cre_Exh_Imtg_1(); + + // Register the applet with the JCRE. + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + //register to EVENT_STATUS_COMMAND + thisApplet.obReg.requestPollInterval((short)POLL_SYSTEM_DURATION); + //register to EVENT_PROFILE_DOWNLOAD + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT_EVENT_DOWNLOAD_MT_CALL + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + } + + + /** + * This method will be used to trigger the tests. + * The application will be triggered by an Formatted SMS PP download event. + * @param event + */ + + public void processToolkit (short event) throws ToolkitException { + byte testCaseNb = (byte) 0x00; + boolean bRes = false; + + + if (event == EVENT_PROFILE_DOWNLOAD) { + + /*------------------------------------------------------------------ + * TC 01: Throw NullPointerException for EVENT_PROFILE_DOWNLOAD + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x01; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + throw new NullPointerException(); + } + + if (event == EVENT_STATUS_COMMAND) { + + /*------------------------------------------------------------------ + * TC 02: Throw NullPointerException for EVENT_STATUS_COMMAND + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x02; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + throw new NullPointerException(); + } + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TC 03: Throw NullPointerException for EVENT_UNRECOGNIZED_ENVELOPE + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x03; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + throw new NullPointerException(); + } + + if (event == EVENT_EVENT_DOWNLOAD_MT_CALL) { + + /*------------------------------------------------------------------ + * TC 04: Throw NullPointerException for EVENT_EVENT_DOWNLOAD_MT_CALL + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x04; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + throw new NullPointerException(); + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Cre_Exh_Imtg_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Cre_Exh_Imtg_2.java new file mode 100644 index 0000000000000000000000000000000000000000..72728a9ff1fc79876de4ff6149e2bfa6dd49cb3c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Cre_Exh_Imtg_2.java @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.catre.cre_exh_imtg; + + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- + +import uicc.toolkit.*; +import uicc.test.util.* ; + + +public class Cre_Exh_Imtg_2 extends TestToolkitApplet { + + + /** + * The Constructor registers the application for the Event. + */ + + private Cre_Exh_Imtg_2() { + } + + + /** + * This method will be used to install the Applet. + */ + + public static void install(byte[] bArray, short bOffset, byte bLength) { + Cre_Exh_Imtg_2 thisApplet = new Cre_Exh_Imtg_2(); + + // Register the applet with the JCRE. + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + //register to EVENT_STATUS_COMMAND + thisApplet.obReg.requestPollInterval((short)POLL_SYSTEM_DURATION); + //register to EVENT_PROFILE_DOWNLOAD + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT_EVENT_DOWNLOAD_MT_CALL + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + } + + + /** + * This method will be used to trigger the tests. + * The application will be triggered by an Formatted SMS PP download event. + * @param event + */ + + public void processToolkit (short event) throws ToolkitException { + byte testCaseNb = (byte) 0x00; + boolean bRes = false; + + if (event == EVENT_STATUS_COMMAND) { + + /*------------------------------------------------------------------ + * TC 01: EVENT_STATUS_COMMAND + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x01; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + + if (event == EVENT_PROFILE_DOWNLOAD) { + + /*------------------------------------------------------------------ + * TC 02: EVENT_PROFILE_DOWNLOAD + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x02; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /*------------------------------------------------------------------ + * TC 03: EVENT_UNRECOGNIZED_ENVELOPE + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x03; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + + if (event == EVENT_EVENT_DOWNLOAD_MT_CALL) { + + /*------------------------------------------------------------------ + * TC 04: EVENT_EVENT_DOWNLOAD_MT_CALL + *----------------------------------------------------------------*/ + testCaseNb=(byte)0x04; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Test_Cre_Exh_Imtg.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Test_Cre_Exh_Imtg.java new file mode 100644 index 0000000000000000000000000000000000000000..501323d7dbba74dfd43dc329631681ba088952d3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/Test_Cre_Exh_Imtg.java @@ -0,0 +1,131 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_exh_imtg; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Exh_Imtg extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_exh_imtg"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Exh_Imtg() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Trigger applets with Terminal Profile + test.reset(); + test.terminalProfileSession("01010000 03"); + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Trigger applets with Status command + response = test.status("00","00","16"); + result = response.getData().regionMatches(16, "3F00", 0, 4); + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Trigger applets with unrecognized envelope + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Trigger applets with unrecognized envelope + response = test.envelopeEventDownloadMTCall(); + result &= response.checkSw("9000"); + + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04" + "CCCCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "04" + "CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..56ac7ce0bd8bd79bdd2fcdba92ec186e942f4856 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_exh_imtg.Cre_Exh_Imtg_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_exh_imtg.Cre_Exh_Imtg_1 +uicc.test.catre.cre_exh_imtg +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/javacard/cre_exh_imtg.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/javacard/cre_exh_imtg.cap new file mode 100644 index 0000000000000000000000000000000000000000..696a95fc89830341780610d68139d1e82b560b0d Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_exh_imtg/javacard/cre_exh_imtg.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/Cre_Hin_Enhd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/Cre_Hin_Enhd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..558ad6c784b7473d38d1a812092b98ac893beafc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/Cre_Hin_Enhd_1.java @@ -0,0 +1,466 @@ +//----------------------------------------------------------------------------- +// Cre_Hin_Enhd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_enhd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Hin_Enhd_1 extends TestToolkitApplet{ + + + private byte testCaseNb = (byte) 0x00; + private boolean bRes; + + private static byte[]bufferCC={(byte)0x82,(byte)0x02,(byte)0x82,(byte)0x81,(byte)0x86,(byte)0x02, + (byte)0x81,(byte)0x01,(byte)0x93,(byte)0x07,(byte)0x81,(byte)0xF2, + (byte)0xA3,(byte)0x34,(byte)0x05,(byte)0x76,(byte)0x67}; + private byte value; + + private static byte[] menuEntry1={(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'1'}; + private static byte[] menuEntry2={(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'2'}; + private byte[] TEXT = {(byte)'T',(byte)'E',(byte)'X',(byte)'T',(byte)' ',(byte)'1'}; + private static byte[] buffer1=new byte[(byte)0x7F]; + private static byte[] buffer2=new byte[(byte)0x7F]; + + private boolean secondTrigger=false; + + + private static short[] eventList ={(byte)12,(byte)13,(byte)14,(byte)15,(byte)16,(byte)17,(byte)18, (byte)20, (byte)21, (byte)22, (byte)23, (byte)25, (byte)26, (byte)28, (byte)29}; + + private static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + private static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + private static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + private static byte[] SERVICE_RECORD = {(byte)0x00, (byte)0x00, (byte)0x00}; + + //External File Update TLV Values + private static byte[] devIdentity = {(byte)0x82, (byte)0x81}; + //EF TARU + private static byte[] baFileList = {(byte)0x01, (byte)0x3F, (byte)0x00, (byte)0x7F, (byte)0x4A, (byte)0x6F, (byte)0x03}; + //EF LARU + private static byte[] baFileListADF = {(byte)0x01, (byte)0x3F, (byte)0x00, (byte)0x7F, (byte)0xFF, (byte)0x7F, (byte)0x4A, (byte)0x6F, (byte)0x0C}; + private static byte[] aid = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + private static byte[] aidNull = null; + private static byte[] fileUpdateInfoTARU = {(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x03}; + private static byte[] fileUpdateInfoLARU = {(byte)0x00, (byte)0x01, (byte)0x00, (byte)0x04}; + private static byte serviceId = (byte) 0; + private static byte a; + + /** + * Constructor of the applet + */ + public Cre_Hin_Enhd_1() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Hin_Enhd_1 thisApplet = new Cre_Hin_Enhd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry1,(short)0,(short)menuEntry1.length,(byte)0,false,(byte)0,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + thisApplet.obReg.initMenuEntry(menuEntry2,(short)0,(short)menuEntry2.length,(byte)0,true,(byte)0,(short)0); + //register to EVENT_TIMER_EXPIRATION + for(a=0; a<(byte)8; a++){ + thisApplet.obReg.allocateTimer(); + } + for(a=2; a<(byte)9; a++){ + thisApplet.obReg.releaseTimer((byte)a); + } + //register to all event download + thisApplet.obReg.setEventList(eventList,(short)0,(short)eventList.length); + //register to EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + serviceId = thisApplet.obReg.allocateServiceIdentifier(); + SERVICE_RECORD[1]= (byte) serviceId; + //register to EVENT_EXTERNAL_FILE_UPDATE + thisApplet.obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,(byte[]) baFileListADF,(short) 0, (short) baFileListADF.length, (byte[]) aid, (short) 0, (byte) aid.length); + thisApplet.obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,(byte[]) baFileList,(short) 0, (short) baFileList.length, (byte[]) aidNull, (short) 0, (byte) 0); + + } + + + public void processToolkit(short event) + { + + bRes=true; + + //the handler contents is stored in buffer 1 + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + //for each event a tlv is selected the first byte is stored + if(!secondTrigger && bRes){ + + //the handler contents is stored in buffer 1 + try{ + envHdlr.copy(buffer1,(short)0,envHdlr.getLength()); + } + catch(Exception e){ + bRes=false; + } + + switch(event){ + + //event EVENT_MENU_SELECTION_HELP_REQUEST + case EVENT_MENU_SELECTION_HELP_REQUEST: + if(envHdlr.findTLV((byte)(TAG_HELP_REQUEST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value = (byte)0x00; + if(envHdlr.getTag()!=(byte)0xD3){ + bRes=false; + } + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + /* Open a channel qualifier = 01 */ + prHdlr.init(PRO_CMD_OPEN_CHANNEL,(byte) 0x01, DEV_ID_TERMINAL); + prHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)ADDRESS_VALUE.length); + prHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)BEARER_VALUE.length); + prHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)BUFFER_SIZE_VALUE.length); + prHdlr.send(); + + /* Declare service add new service*/ + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte) 0x00, DEV_ID_TERMINAL); + prHdlr.appendTLV(TAG_SERVICE_RECORD, SERVICE_RECORD, (short)0, (short) SERVICE_RECORD.length); + prHdlr.send(); + + break; + + //event EVENT_MENU_SELECTION + case EVENT_MENU_SELECTION: + if(envHdlr.findTLV((byte)(TAG_ITEM_IDENTIFIER|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value = (byte)0x01; + break; + + //event EVENT_TIMER_EXPIRATION + case EVENT_TIMER_EXPIRATION: + if(envHdlr.findTLV((byte)(TAG_TIMER_IDENTIFIER|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value = (byte)0x01; + break; + + //event EVENT_CALL_CONTROL_BY_NAA + case EVENT_CALL_CONTROL_BY_NAA: + if(envHdlr.findTLV((byte)(TAG_ADDRESS|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value = (byte) 0x81; + break; + + //event EVENT_EVENT_DOWNLOAD_MT_CALL + case EVENT_EVENT_DOWNLOAD_MT_CALL: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value =(byte)0x00; + break; + + //event EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + case EVENT_EVENT_DOWNLOAD_CALL_CONNECTED: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value = (byte)0x01; + break; + + //event EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + case EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value =(byte)0x02; + break; + + //event EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + case EVENT_EVENT_DOWNLOAD_LOCATION_STATUS: + if(envHdlr.findTLV((byte)(TAG_LOCATION_STATUS|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value =(byte)0x01; + break; + + //event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + case EVENT_EVENT_DOWNLOAD_USER_ACTIVITY: + if(envHdlr.findTLV((byte)(TAG_DEVICE_IDENTITIES|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value =(byte)0x82; + break; + + //event EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + case EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE: + if(envHdlr.findTLV((byte)(TAG_DEVICE_IDENTITIES|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value =(byte)0x02; + break; + + //event EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + case EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS: + if(envHdlr.findTLV((byte)(TAG_CARD_READER_STATUS|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0xFF; + break; + + //event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + case EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x07; + break; + + //event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + case EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x08; + break; + + //event EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + case EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x09; + break; + + //event EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + case EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x0A; + break; + + //event EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + case EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x0B; + break; + + //event EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x0C; + break; + + //event EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + case EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x0D; + break; + + //event EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + case EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x0E; + break; + + //event EVENT_EVENT_BROWSING_STATUS + case EVENT_EVENT_BROWSING_STATUS: + if(envHdlr.findTLV((byte)(TAG_EVENT_LIST|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x0F; + break; + + //event EVENT_EXTERNAL_FILE_UPDATE + case EVENT_EXTERNAL_FILE_UPDATE: + if(envHdlr.findTLV((byte)(TAG_DEVICE_IDENTITIES|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + value=(byte)0x82; + break; + + + + + } + + if(bRes){ + //A Display text is sent + secondTrigger=true; + ProactiveHandler prHdlr = ProactiveHandlerSystem.getTheHandler(); + prHdlr.initDisplayText((byte)0x80,(byte)0x04,TEXT,(short)0,(short)TEXT.length); + prHdlr.send(); + //the handler contents is stored in buffer 2 + if(bRes) + { + if(event==EVENT_MENU_SELECTION_HELP_REQUEST){ + //Copy the envelope contents in buffer 2 + envHdlr.copy(buffer2,(short)0,envHdlr.getLength()); + //the contents of buffer1 and buffer2 must be equals + if((byte)Util.arrayCompare(buffer1,(short)0,buffer2,(short)0,(short)envHdlr.getLength())==0){ + bRes=true; + } + else{ + bRes=false; + } + + } + else{ + try{ + //the selected tlv is the same before the call control execution + if(envHdlr.getValueByte((short)0)==(byte)value){ + + //Copy the envelope contents in buffer 2 + envHdlr.copy(buffer2,(short)0,envHdlr.getLength()); + //the contents of buffer1 and buffer2 must be equals + if((byte)Util.arrayCompare(buffer1,(short)0,buffer2,(short)0,(short)envHdlr.getLength())==0){ + bRes=true; + } + else{ + bRes=false; + } + } + else{ + bRes=false; + } + + if (event==EVENT_EXTERNAL_FILE_UPDATE){ + + //Device Identity + if(envHdlr.findAndCompareValue((byte) (TAG_DEVICE_IDENTITIES|TAG_SET_CR), + (byte[]) devIdentity, (short) 0)!=0){ + bRes=false; + } + //AID + //if Tag AID does not exist the file belongs to the UICC + if(envHdlr.findTLV((byte)(TAG_AID|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + + if(envHdlr.findAndCompareValue((byte) (TAG_FILE_LIST |TAG_SET_CR), + (byte[]) baFileList, (short) 0)!=0){ + bRes=false; + } + //File Update Information. Transparent + if(envHdlr.findAndCompareValue((byte) (0x3B|TAG_SET_CR), + (byte[]) fileUpdateInfoTARU, (short) 0)!=0){ + bRes=false; + } + + }else{ + //if exist Tag AID the file belongs to an ADF + if(envHdlr.compareValue((short) 0, (byte[]) aid, (short) 0, (short) aid.length)!=0){ + bRes=false; + } + + if(envHdlr.findAndCompareValue((byte) (TAG_FILE_LIST |TAG_SET_CR), + (byte[]) baFileListADF, (short) 0)!=0){ + bRes=false; + } + //File Update Information. Linear fixed + if(envHdlr.findAndCompareValue((byte) (0x3B|TAG_SET_CR), + (byte[]) fileUpdateInfoLARU, (short) 0)!=0){ + bRes=false; + } + } + + } + + } + catch(ToolkitException e){ + //if the event is an UNRECOGNIZED envelope no TLV is selected + if(event==EVENT_UNRECOGNIZED_ENVELOPE && e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT ){ + bRes=true; + } + else{ + bRes=false; + } + } + catch(Exception e){ + bRes=false; + } + } + } + + } + testCaseNb++; + //create the table of results + reportTestOutcome(testCaseNb,bRes); + + } + //The applet is triggered when a EVENT CALL CONTROL is sent + else{ + secondTrigger=false; + try{ + EnvelopeHandler envHdlrCC = EnvelopeHandlerSystem.getTheHandler(); + + //the handler contents is stored + envHdlrCC.copy(buffer2,(short)0,(short)envHdlrCC.getLength()); + + //is checked that the envelope is a call control + if(Util.arrayCompare(buffer2,(short)0x00,bufferCC,(short)0x00,(short)envHdlrCC.getLength())!=0){ + bRes=false; + } + //the device identities TLV is selected + if(envHdlrCC.findTLV((byte)(TAG_DEVICE_IDENTITIES|TAG_SET_CR),(byte)1)==TLV_NOT_FOUND){ + bRes=false; + } + } + catch(Exception e){ + bRes=false; + } + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/Test_Cre_Hin_Enhd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/Test_Cre_Hin_Enhd.java new file mode 100644 index 0000000000000000000000000000000000000000..d1a138e58a354bfa8b8f46d158663b28c824ba23 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/Test_Cre_Hin_Enhd.java @@ -0,0 +1,371 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_enhd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Hin_Enhd extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_hin_enhd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + static final String MF = "3F00"; + static final String ADF = "7FFF"; + static final String FID_DF_TEST = "7F4A"; + static final String FID_EF_TARU = "6F03"; + static final String FID_EF_LARU = "6F0C"; + + static String declareService; + static String serviceRecordTLV; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Hin_Enhd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("A8970121 FEEF0081 010000FF FF"); + // ----------------------------------------------------------------------- + // Test Case 1 : Applet initialization and Envelope Handler integrity + // checks with EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------------- + + //event EVENT_MENU_SELECTION_HELP_REQUEST + response = test.envelopeMenuSelection("100102", "1500"); + + //Open Channel + result = response.checkSw("911A"); + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + response = test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + + //Declare Service + result &= response.checkSw("9110"); + response = test.fetch("10"); + declareService = response.getData(); + serviceRecordTLV = declareService.substring(22,32); //to get ServiceId + result &= response.checkData("D00E8103 01470082 028182" + serviceRecordTLV); + response = test.terminalResponse("81030147 00820282 81830100"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_MENU_SELECTION + response = test.envelopeMenuSelection("100101", ""); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_TIMER_EXPIRATION + response = test.envelopeTimerExpiration("240101"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_CALL_CONTROL_BY_NAA + response = test.envelopeCallControlByNAA(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_MT_CALL + response = test.envelopeEventDownloadMTCall(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + response = test.envelopeEventDownloadCallConnected(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + response = test.envelopeEventDownloadCallDisconnected(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + response = test.envelopeEventDownloadLocationStatus(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + response = test.envelopeEventDownloadUserActivity(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + response = test.envelopeEventDownloadIdleScreenAvailable(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + response = test.envelopeEventDownloadCardReaderStatus(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_UNRECOGNIZED_ENVELOPE + response = test.unrecognizedEnvelope(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + response = test.envelopeEventDownloadLanguageSelection(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + response = test.envelopeEventDownloadBrowserTermination(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38028100"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38028100"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + response = test.envelopeEventDownloadAccessTechnologyChange(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + response = test.envelopeEventDownloadDisplayParametersChanged(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + response = test.envelopeEventDownloadLocalConnection(serviceRecordTLV); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + response = test.envelopeEventDownloadNetworkSearchModeChange(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EVENT_BROWSING_STATUS + response = test.envelopeEventDownloadBrowsingStatus(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + + //event EVENT_EXTERNAL_FILE_UPDATE UICC + test.selectFile(MF); + test.selectFile(FID_DF_TEST); + test.selectFile(FID_EF_TARU);//EF TARU + response = test.updateBinary("0000", "FFFFFF"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + //event EVENT_EXTERNAL_FILE_UPDATE ADF + test.selectApplication("A0000000090005FFFFFFFF89E0000002"); + test.selectFile(ADF); + test.selectFile(FID_DF_TEST); + test.selectFile(FID_EF_LARU);//EF LARU + response = test.updateRecord("01", "04", "55555555"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.envelopeCallControlByNAA(); + response = test.terminalResponse("81030121 80820282 81030100"); + + + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "17CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2dcc21391128fb5ea2af26944bb4ed014404d14d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_hin_enhd.Cre_Hin_Enhd_1 +uicc.test.catre.cre_hin_enhd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/javacard/cre_hin_enhd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/javacard/cre_hin_enhd.cap new file mode 100644 index 0000000000000000000000000000000000000000..04e4f8feb7b022dd63437341d97b2d82a9aa042c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_enhd/javacard/cre_hin_enhd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/Cre_Hin_Erhd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/Cre_Hin_Erhd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec173b4be056ad12a3dbb785db1ca592a2b7f06 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/Cre_Hin_Erhd_1.java @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------------- +// Cre_Hin_Erhd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_erhd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Hin_Erhd_1 extends TestToolkitApplet{ + + + + /** + * Constructor of the applet + */ + public Cre_Hin_Erhd_1() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Hin_Erhd_1 thisApplet = new Cre_Hin_Erhd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + public void processToolkit(short event) + { + + boolean bRes = false; + byte bTestCaseNb = (byte)1; + + try{ + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + if (envRespHdlr.getLength()==(short)0x0000){ + bRes=true; + } + } + catch (Exception e) { + bRes=false; + } + + reportTestOutcome ( bTestCaseNb, bRes ); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/Test_Cre_Hin_Erhd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/Test_Cre_Hin_Erhd.java new file mode 100644 index 0000000000000000000000000000000000000000..d700aa76d7932468e414943790910bb038251934 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/Test_Cre_Hin_Erhd.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_erhd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Hin_Erhd extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_hin_erhd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Hin_Erhd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + test.reset(); + test.terminalProfileSession("0101"); + + /*******************************************************************************************/ + /** Testcase 1 At the processToolkit invocation the TLV-List is cleared */ + /*******************************************************************************************/ + + + // 1- Trigger AppletA1 + test.unrecognizedEnvelope(); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "01CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ec9af31efbe3a442953bc18cdbcc6b75866b6123 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_hin_erhd.Cre_Hin_Erhd_1 +uicc.test.catre.cre_hin_erhd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/javacard/cre_hin_erhd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/javacard/cre_hin_erhd.cap new file mode 100644 index 0000000000000000000000000000000000000000..33805fcc0cdf0575639a4048a8cd2318d69415ca Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_erhd/javacard/cre_hin_erhd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Cre_Hin_Pahd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Cre_Hin_Pahd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..510cb7d3b2af03c14e5bf9433a2d80fdae3d3fc5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Cre_Hin_Pahd_1.java @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------- +// Cre_Hin_Pahd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_pahd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Hin_Pahd_1 extends TestToolkitApplet{ + + + byte[] dstBuffer = new byte[9]; + byte[] data = new byte[9]; + + short dataOffset; + short dataLength; + short dstLength; + + /** + * Constructor of the applet + */ + public Cre_Hin_Pahd_1() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Hin_Pahd_1 thisApplet = new Cre_Hin_Pahd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + } + + + public void processToolkit(short event) + { + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + // Get the system instance of handlers + ProactiveHandler proactiveHdlr = ProactiveHandlerSystem.getTheHandler(); + + // ----------------------------------------------------------------------- + // Test Case 1 : At the processToolkit invocation the TLV-List is cleared + // ----------------------------------------------------------------------- + bTestCaseNb = (byte)1; + + try{ + bRes = (proactiveHdlr.getLength() == (short)0); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + + // ----------------------------------------------------------------------- + // Test Case 2 : TLV-List change after the init method invocation + // ----------------------------------------------------------------------- + + bTestCaseNb = (byte)2; + + try{ + proactiveHdlr.init(PRO_CMD_DISPLAY_TEXT, (byte)0x80, DEV_ID_DISPLAY); + bRes = ((dstLength=proactiveHdlr.getLength()) == (short)9); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)dstLength); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + // ----------------------------------------------------------------------- + // Test Case 3 : The TLV-List remains unchanged after the send() method invocation + // ----------------------------------------------------------------------- + bRes = false; + bTestCaseNb = (byte)3; + + try{ + proactiveHdlr.send(); + bRes = ((dstLength=proactiveHdlr.getLength()) == (short)9); + proactiveHdlr.copy((byte[]) data, (short) 0, (short)dstLength); + if (Util.arrayCompare(data, (short)0, dstBuffer, (short)0, (short)9)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Cre_Hin_Pahd_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Cre_Hin_Pahd_2.java new file mode 100644 index 0000000000000000000000000000000000000000..da311602e3b710d42bbcb9191a0fccafc8b04ad4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Cre_Hin_Pahd_2.java @@ -0,0 +1,209 @@ +//----------------------------------------------------------------------------- +// Cre_Hin_Pahd_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_pahd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Hin_Pahd_2 extends TestToolkitApplet{ + + + byte[] dstBuffer = new byte[20]; + + public static byte[] init = {(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x80, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x02}; + public static byte[] initCloseChannel = {(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x41, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x21}; + public static byte[] initDisplayText = {(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x02, (byte) 0x8D, (byte) 0x05, (byte) 0x00, (byte) 0x54, (byte) 0x65, (byte) 0x78, (byte) 0x74}; + public static byte[] initGetInkey = {(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x22, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x82, (byte) 0x8D, (byte) 0x05, (byte) 0x00, (byte) 0x54, (byte) 0x65, (byte) 0x78, (byte) 0x74}; + public static byte[] initGetInput = {(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x23, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x82, (byte) 0x8D, (byte) 0x05, (byte) 0x00, (byte) 0x54, (byte) 0x65, (byte) 0x78, (byte) 0x74, (byte) 0x91, (byte) 0x02, (byte) 0x05, (byte) 0x07}; + public static byte[] initMoreTime = {(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x82}; + + byte qualifier=0x00; //displayText, getInkey, getInput + byte dcs=0x00; //displayText, getInkey, getInput + public static byte[] buffer = {(byte) 0x54, (byte) 0x65,(byte) 0x78, (byte) 0x74};//Text + short minRespLength=0x05; + short maxRespLength=0x07; + + /** + * Constructor of the applet + */ + public Cre_Hin_Pahd_2() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Hin_Pahd_2 thisApplet = new Cre_Hin_Pahd_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + } + + + public void processToolkit(short event) + { + + + boolean bRes = false; + byte bTestCaseNb = (byte)0; + + // Get the system instance of handlers + ProactiveHandler proactiveHdlr = ProactiveHandlerSystem.getTheHandler(); + + // ----------------------------------------------------------------------- + // Test Case 4 : At the processToolkit invocation the TLV-List is cleared + // ----------------------------------------------------------------------- + bTestCaseNb = (byte)1; + + try{ + bRes = (proactiveHdlr.getLength() == (short)0); + proactiveHdlr.getValueLength(); + bRes = false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + + // ----------------------------------------------------------------------- + // Test Case 5 : At the call of its init method the content is cleared and then initialized + // ----------------------------------------------------------------------- + bRes = false; + bTestCaseNb = (byte)2; + + //init + try{ + proactiveHdlr.init(PRO_CMD_DISPLAY_TEXT, (byte)0x80, DEV_ID_DISPLAY); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(init, (short)0, dstBuffer, (short)0, (short)init.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + + bRes = false; + bTestCaseNb = (byte)3; + + //initCloseChannel + try{ + proactiveHdlr.initCloseChannel((byte) 0x01); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(initCloseChannel, (short)0, dstBuffer, (short)0, (short)initCloseChannel.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + bRes = false; + bTestCaseNb = (byte)4; + + //initDisplayText + try{ + proactiveHdlr.initDisplayText((byte) qualifier,(byte) dcs,(byte[]) buffer, (short) 0, (short) buffer.length); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(initDisplayText, (short)0, dstBuffer, (short)0, (short)initDisplayText.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + bRes = false; + bTestCaseNb = (byte)5; + + //initGetInkey + try{ + proactiveHdlr.initGetInkey((byte) qualifier,(byte) dcs,(byte[]) buffer, (short) 0, (short) buffer.length); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(initGetInkey, (short)0, dstBuffer, (short)0, (short)initGetInkey.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + bRes = false; + bTestCaseNb = (byte)6; + + //initGetInput + try{ + proactiveHdlr.initGetInput((byte) qualifier,(byte) dcs,(byte[]) buffer, (short) 0,(short) buffer.length,(short) minRespLength,(short) maxRespLength); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(initGetInput, (short)0, dstBuffer, (short)0, (short)initGetInput.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + bRes = false; + bTestCaseNb = (byte)7; + + //initMoreTime + try{ + proactiveHdlr.initMoreTime(); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(initMoreTime, (short)0, dstBuffer, (short)0, (short)initMoreTime.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + bRes = false; + bTestCaseNb = (byte)8; + + //init + try{ + proactiveHdlr.init(PRO_CMD_DISPLAY_TEXT, (byte)0x80, DEV_ID_DISPLAY); + proactiveHdlr.copy((byte[]) dstBuffer, (short) 0, (short)proactiveHdlr.getLength()); + if (Util.arrayCompare(init, (short)0, dstBuffer, (short)0, (short)init.length)==0) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome ( bTestCaseNb, bRes ); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Test_Cre_Hin_Pahd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Test_Cre_Hin_Pahd.java new file mode 100644 index 0000000000000000000000000000000000000000..17836c47699f4aeec349316ad239939ccb1c5911 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/Test_Cre_Hin_Pahd.java @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_pahd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Hin_Pahd extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_hin_pahd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Hin_Pahd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("01810F00 21000008 01000002"); + + /*******************************************************************************************/ + /** Testcase 1 At the processToolkit invocation the TLV-List is cleared */ + /** Testcase 2 TLV-List change after the init method invocation */ + /** Testcase 3 The TLV-List remains unchanged after the send() method invocation */ + /** Testcase 4 At the processToolkit invocation the TLV-List is cleared */ + /** Testcase 5 At the call of its init method the content is cleared and then initialized */ + /*******************************************************************************************/ + + + // 1- Trigger AppletA1 + test.envelopeEventDownloadUserActivity(); + response = test.fetch("0B"); + result = response.checkData("D0098103 01218082 028102"); + test.terminalResponse("81030121 80820282 81830100"); + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "03CCCCCC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + + "08CCCCCC CCCCCCCC CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet1 + // delete Applet2 + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..272d14970795c85c23f511a5d0bebbcf6257f67a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_hin_pahd.Cre_Hin_Pahd_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_hin_pahd.Cre_Hin_Pahd_1 +uicc.test.catre.cre_hin_pahd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/javacard/cre_hin_pahd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/javacard/cre_hin_pahd.cap new file mode 100644 index 0000000000000000000000000000000000000000..076a2943339cd3904440b841c074e2b451e2cecd Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_pahd/javacard/cre_hin_pahd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/Cre_Hin_Prhd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/Cre_Hin_Prhd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b53bcea9d80bbc562691e7609b79060562a5a74d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/Cre_Hin_Prhd_1.java @@ -0,0 +1,233 @@ +//----------------------------------------------------------------------------- +// Cre_Hin_Prhd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_prhd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Hin_Prhd_1 extends TestToolkitApplet{ + + + private byte[] TEXT = {(byte)'T',(byte)'E',(byte)'X',(byte)'T',(byte)' ',(byte)'1'}; + private static byte[] menuEntry1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'1'}; + private static byte[] menuEntry2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'2'}; + private static short[] eventList ={(byte)12,(byte)13,(byte)14,(byte)15,(byte)16,(byte)17,(byte)18, (byte)20, (byte)21, (byte)22, (byte)23, (byte)25, (byte)26, (byte)28, (byte)29}; + + private static byte[] baFileList = {(byte)0x01, (byte)0x3F, (byte)0x00, (byte)0x7F, (byte)0x4A, (byte)0x6F, (byte)0x03}; + private static byte[] aid=null; + + private boolean bRes; + private byte bTestCaseNb = (byte) 0; + private boolean firstTrigger = true; + + private static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + private static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + private static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + private static byte[] SERVICE_RECORD = {(byte)0x00, (byte)0x00, (byte)0x00}; + private static byte serviceId = (byte) 0; + + private static byte a; + + /** + * Constructor of the applet + */ + public Cre_Hin_Prhd_1() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Hin_Prhd_1 thisApplet = new Cre_Hin_Prhd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry1,(short)0,(short)menuEntry1.length,(byte)0,false,(byte)0,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + thisApplet.obReg.initMenuEntry(menuEntry2,(short)0,(short)menuEntry2.length,(byte)0,true,(byte)0,(short)0); + //register to EVENT_TIMER_EXPIRATION + try{ + + for(a=0; a<(byte)8; a++){ + thisApplet.obReg.allocateTimer(); + } + for(a=2; a<(byte)9; a++){ + thisApplet.obReg.releaseTimer((byte)a); + } + } + catch(Exception e){ + } + //register to all event download + thisApplet.obReg.setEventList(eventList,(short)0,(short)eventList.length); + //register to EVENT_STATUS_COMMAND + thisApplet.obReg.requestPollInterval((short)POLL_SYSTEM_DURATION); + //register to EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + serviceId = thisApplet.obReg.allocateServiceIdentifier(); + SERVICE_RECORD[1]= (byte) serviceId; + // register to EVENT_EXTERNAL_FILE_UPDATE on update of EF Taru of UICC file system + thisApplet.obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,(byte[]) baFileList,(short) 0, (short) baFileList.length, (byte[]) aid, (short) 0, (byte) 0); + + } + + + public void processToolkit(short event) { + ProactiveHandler prHdlr; + ProactiveResponseHandler prRespHdlr; + + switch(event){ + + //event EVENT_PROFILE_DOWNLOAD + case EVENT_PROFILE_DOWNLOAD: + //event EVENT_PROACTIVE_HANDLER_AVAILABLE + case EVENT_PROACTIVE_HANDLER_AVAILABLE: + //event EVENT_MENU_SELECTION + case EVENT_MENU_SELECTION: + //event EVENT_MENU_SELECTION_HELP_REQUEST + case EVENT_MENU_SELECTION_HELP_REQUEST: + //event EVENT_CALL_CONTROL_BY_NAA + case EVENT_CALL_CONTROL_BY_NAA: + //event EVENT_TIMER_EXPIRATION + case EVENT_TIMER_EXPIRATION: + //event EVENT_EVENT_DOWNLOAD_MT_CALL + case EVENT_EVENT_DOWNLOAD_MT_CALL: + //event EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + case EVENT_EVENT_DOWNLOAD_CALL_CONNECTED: + //event EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + case EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED: + //event EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + case EVENT_EVENT_DOWNLOAD_LOCATION_STATUS: + //event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + case EVENT_EVENT_DOWNLOAD_USER_ACTIVITY: + //event EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + case EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE: + //event EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + case EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS: + //event EVENT_STATUS_COMMAND + case EVENT_STATUS_COMMAND: + //event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + case EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION: + //event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + case EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION: + //event EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + case EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE: + //event EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + case EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS: + //event EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + case EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE: + //event EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + //event EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + case EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION: + //event EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + case EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE: + //event EVENT_EVENT_BROWSING_STATUS + case EVENT_EVENT_BROWSING_STATUS: + //event EVENT_EXTERNAL_FILE_UPDATE + case EVENT_EXTERNAL_FILE_UPDATE: + //event EVENT_UNRECOGNIZED_ENVELOPE + case EVENT_UNRECOGNIZED_ENVELOPE: + + // ----------------------------------------------------------------------- + // Test Case 1 : Applet registration and ProactiveResponseHandler obtaining + // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- + // Test Case 2 : The ProactiveResponseHandler remains unchanged after + // send() method invocation until next send() method invocation + // ----------------------------------------------------------------------- + bRes = false; + bTestCaseNb++; + try{ + try{ + + // Get the system instance of handlers + prRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + prHdlr = ProactiveHandlerSystem.getTheHandler(); + bRes = (prRespHdlr.getLength() == (short)0); + + + + if (firstTrigger) { + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + + /* Open a channel qualifier = 01 */ + prHdlr.init(PRO_CMD_OPEN_CHANNEL,(byte) 0x01, DEV_ID_TERMINAL); + prHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)ADDRESS_VALUE.length); + prHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)BEARER_VALUE.length); + prHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)BUFFER_SIZE_VALUE.length); + prHdlr.send(); + + /* Declare service add new service*/ + prHdlr.init(PRO_CMD_DECLARE_SERVICE,(byte) 0x00, DEV_ID_TERMINAL); + prHdlr.appendTLV(TAG_SERVICE_RECORD, SERVICE_RECORD, (short)0, (short) SERVICE_RECORD.length); + prHdlr.send(); + + firstTrigger = false; + } + + + + } catch (Exception e) { + bRes = false; + } + + if(bRes){ + //get the Proactive Handler and the Proactive Response Handler + prHdlr = ProactiveHandlerSystem.getTheHandler(); + //build a Proactive Command Display Text + prHdlr.initDisplayText((byte)0x80,(byte)0x04,TEXT,(short)0,(short)TEXT.length); + //send the command Display Text + if(prHdlr.send()==0){ + //The ProactiveResponseHandler contains the terminal response + prRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + //the handler length should be 12 + if(prRespHdlr.getLength()==(byte)12){ + //No exception is thrown and the Proactive Response Handler remains unchanged + prHdlr.init(PRO_CMD_SELECT_ITEM,(byte)0x00,DEV_ID_TERMINAL); + prHdlr.appendTLV((byte)(TAG_ITEM_IDENTIFIER|TAG_SET_CR),(byte)0x01); + if(prHdlr.send()==0){ + prRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + //The ProactiveResponseHandler contains the terminal response of the second proactive command + //the handler length should be 15 + if(prRespHdlr.getLength()!=(byte)15){ + bRes=false; + } + } else{ + bRes=false; + } + } else{ + bRes=false; + } + } else{ + bRes=false; + } + } + + } catch (Exception e) { + bRes = false; + } + reportTestOutcome( bTestCaseNb, bRes ); + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/Test_Cre_Hin_Prhd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/Test_Cre_Hin_Prhd.java new file mode 100644 index 0000000000000000000000000000000000000000..e3a8ffb3abc9da204c245d69d14b682cbf1e26f6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/Test_Cre_Hin_Prhd.java @@ -0,0 +1,534 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_hin_prhd; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Hin_Prhd extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_hin_prhd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + static final String MF = "3F00"; + static final String FID_DF_TEST = "7F4A"; + static final String FID_EF_TARU = "6F03"; + + static String declareService; + static String serviceRecordTLV; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Hin_Prhd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + + // ----------------------------------------------------------------------- + // Test Case 1 : Applet registration and ProactiveResponseHandler obtaining + // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- + // Test Case 2 : The ProactiveResponseHandler remains unchanged after + // send() method invocation until next send() method invocation + // ----------------------------------------------------------------------- + + //event EVENT_PROFILE_DOWNLOAD + test.reset(); + response = test.terminalProfile("A8970101 FEEF0081 010000FF FF"); + + //Open Channel + result = response.checkSw("911A"); + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + response = test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + + //Declare Service + result &= response.checkSw("9110"); + response = test.fetch("10"); + declareService = response.getData(); + serviceRecordTLV = declareService.substring(22,32); //to get ServiceId + result &= response.checkData("D00E8103 01470082 028182" + serviceRecordTLV); + response = test.terminalResponse("81030147 00820282 81830100"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + response = test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_PROACTIVE_HANDLER_AVAILABLE + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + response = test.terminalResponse("81030124 00820282 81030100 900101"); + + //event EVENT_MENU_SELECTION + response = test.envelopeMenuSelection("100101", ""); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_MENU_SELECTION_HELP_REQUEST + response = test.envelopeMenuSelection("100102", "1500"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_CALL_CONTROL_BY_NAA + response = test.envelopeCallControlByNAA(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_TIMER_EXPIRATION + response = test.envelopeTimerExpiration("240101"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_MT_CALL + response = test.envelopeEventDownloadMTCall(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_CALL_CONNECTED + response = test.envelopeEventDownloadCallConnected(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED + response = test.envelopeEventDownloadCallDisconnected(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_LOCATION_STATUS + response = test.envelopeEventDownloadLocationStatus(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + response = test.envelopeEventDownloadUserActivity(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE + response = test.envelopeEventDownloadIdleScreenAvailable(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS + response = test.envelopeEventDownloadCardReaderStatus(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_STATUS_COMMAND + response = test.status("00", "0C", "00"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION + response = test.envelopeEventDownloadLanguageSelection(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION + response = test.envelopeEventDownloadBrowserTermination(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE + response = test.envelopeEventDownloadDataAvailable("38028100"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + response = test.envelopeEventDownloadChannelStatus("38028100"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE + response = test.envelopeEventDownloadAccessTechnologyChange(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED + response = test.envelopeEventDownloadDisplayParametersChanged(); + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + response = test.envelopeEventDownloadLocalConnection(serviceRecordTLV); + //response = test.envelopeEventDownloadLocalConnection("41 03000000"); + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE + response = test.envelopeEventDownloadNetworkSearchModeChange(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EVENT_BROWSING_STATUS + response = test.envelopeEventDownloadBrowsingStatus(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_EXTERNAL_FILE_UPDATE + test.selectFile(MF); + test.selectFile(FID_DF_TEST); + test.selectFile(FID_EF_TARU); + response = test.updateBinary("0000", "FFFFFF"); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + //event EVENT_UNRECOGNIZED_ENVELOPE + response = test.unrecognizedEnvelope(); + + //Display Text + result &= response.checkSw("9114"); + response = test.fetch("14"); + result &= response.checkData("D0128103 01218082 0281028D 07045445" + + "58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + + //Select Item + result &= response.checkSw("910E"); + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01240082 02818290 0101"); + test.terminalResponse("81030124 00820282 81030100 900101"); + + + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "19CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..378afdf19fb4be72fc0477157b7b6021767b400e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_hin_prhd.Cre_Hin_Prhd_1 +uicc.test.catre.cre_hin_prhd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/javacard/cre_hin_prhd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/javacard/cre_hin_prhd.cap new file mode 100644 index 0000000000000000000000000000000000000000..25240a19e468fa441103fc311b6e9bda14b18f16 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_hin_prhd/javacard/cre_hin_prhd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..10e7a6884f5814eceed65c34f720ec100c693b27 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_1.java @@ -0,0 +1,255 @@ +//----------------------------------------------------------------------------- +//CRE_MHA_ENHD +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_enhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + + +import javacard.framework.*; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +public class Cre_Mha_Enhd_1 extends TestToolkitApplet +{ + + /** result of specific testcase */ + private boolean bRes = false; + /** number of testcase */ + private byte testCaseNb = (byte) 0x00; + private boolean handler_available = true; + /** */ + private final byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ', (byte) '1'}; + private final byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ', (byte) '2'}; + private final byte QUALIFIER_1 = (byte) 0x01; + private final byte[] ADDRESS_VALUE = {(byte) 0x81, (byte) 0x55, (byte) 0x66, (byte) 0x77, (byte) 0x88}; + private final byte[] BEARER_VALUE = {(byte) 0x03, (byte) 0x00}; + private final byte[] BUFFER_SIZE_VALUE = {(byte) 0x00, (byte) 0x01}; + protected byte service_id = (byte)0x00; + protected byte[] SERVICE_RECORD_VALUE = {(byte) 0x00, (byte) 0x00, (byte) 0x00}; + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + + + /** list included registered all events */ + private final short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_CALL_CONTROL_BY_NAA, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_APPLICATION_DESELECT, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_PROFILE_DOWNLOAD, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + EVENT_EVENT_BROWSING_STATUS}; + + + + + /** + */ + private Cre_Mha_Enhd_1 () { } + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException + { + Cre_Mha_Enhd_1 applet = new Cre_Mha_Enhd_1(); + + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + //initialize the data of the test applet + applet.init(); + + //- Applet registration + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem2.length,(byte)0x00,true ,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_EVENT_DOWNLLOAD_LOCAL_CONNECTION + applet.service_id = applet.obReg.allocateServiceIdentifier(); + applet.SERVICE_RECORD_VALUE[(byte)0x01]=applet.service_id; + //register to the resto of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + //register to EVENT_TIMER_EXPIRATION + for (byte timer=(byte)0x00;timer<(byte)0x08;timer++){ + applet.obReg.allocateTimer(); + } + for (byte timer=(byte)0x02;timer<=(byte)0x08;timer++){ + //release timer from 2 to 8 to be sure that only timer id 1 is allocated + applet.obReg.releaseTimer(timer); + } + } + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)0x01; + + if (testCaseNb==(byte)0x01 || + testCaseNb==(byte)0x10 || //tc 16 + testCaseNb==(byte)0x17 ) //tc 23 + {handler_available=false;} + + else if (testCaseNb==(byte)0x03 || + testCaseNb==(byte)0x11 || //tc 17 + testCaseNb==(byte)0x13 || + testCaseNb==(byte)0x18) //tc 24 + {handler_available=true;} + + + switch (event) { + //-- TC 1 + case EVENT_FIRST_COMMAND_AFTER_ATR : + testCaseNb=(byte)0x01; + checkHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + //-- TC 2 + case EVENT_PROFILE_DOWNLOAD: + checkHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + //-- TC 16 + case EVENT_STATUS_COMMAND: + try { + EnvelopeHandler envHdr = EnvelopeHandlerSystem.getTheHandler(); + } + catch (ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bRes=true; + this.reportTestOutcome(testCaseNb, bRes); + // Open Channel(1) proactive command for test case 17 + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + proHdr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short) 0, (short) 5); + proHdr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short) 0, (short) 2); + proHdr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short) 0, (short) 2); + proHdr.send(); + bRes=true; + } + } + catch (Exception exp) { + bRes = false; + this.reportTestOutcome(testCaseNb, bRes); + } + + break; + + //-- TC 19 + case EVENT_UNRECOGNIZED_ENVELOPE: + try{ + EnvelopeHandler envHdr = EnvelopeHandlerSystem.getTheHandler(); + //get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + proHdr.init(PRO_CMD_DECLARE_SERVICE, (byte)0, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_SERVICE_RECORD, SERVICE_RECORD_VALUE, (short) 0, (short) 3); + if (proHdr.send() == (byte) 0x00) { + bRes = true; + this.reportTestOutcome(testCaseNb, bRes); + } + + } + catch(Exception exp){ + this.reportTestOutcome(testCaseNb, bRes); + bRes=false; + } + + break; + + + //-- TC 22 + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + try{ + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + EnvelopeHandler envHdr = EnvelopeHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb, bRes); + break; + + //-- TC 24 + case EVENT_APPLICATION_DESELECT: + checkHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + + //-- All other test cases + default : + checkHandler(); + break; + } + } + + /** + * Verify if the envelope handler is available or not + */ + + private boolean checkHandler() + { + bRes=false; + //handler shall be available + if (handler_available==true){ + try { + EnvelopeHandler EnvHdr = EnvelopeHandlerSystem.getTheHandler(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + } + //handler shall not be available + else { + try { + EnvelopeHandler EnvHdr = EnvelopeHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if(exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + } + + this.reportTestOutcome(testCaseNb,bRes); + return bRes; + } + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_2.java new file mode 100644 index 0000000000000000000000000000000000000000..ade5468bd05ca45566d2a23065c13dd596349ab7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_2.java @@ -0,0 +1,192 @@ +//----------------------------------------------------------------------------- +//Cre_Mha_Enhd_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_enhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Enhd_2 extends TestToolkitApplet { + + /** result of specific testcase */ + boolean bRes = false; + /** number of testcase */ + byte testCaseNb = (byte) 0x00; + boolean handler_available = true; + private final byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ', (byte) '1'}; + private final byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ', (byte) '2'}; + protected byte[] SERVICE_RECORD_VALUE = {(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}; + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + /** list included registered all events */ + private short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_APPLICATION_DESELECT, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + EVENT_EVENT_BROWSING_STATUS, + EVENT_PROFILE_DOWNLOAD, + }; + + /** + */ + private Cre_Mha_Enhd_2 () {} + + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException + { + Cre_Mha_Enhd_2 applet = new Cre_Mha_Enhd_2(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + applet.init(); + + //- Applet registration + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem2.length,(byte)0x00,true ,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_TIMER_EXPIRATION + applet.obReg.allocateTimer(); + //register to the resto of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException + { + bRes=false; + testCaseNb+=(byte)0x01; + + if (testCaseNb==(byte)0x01 || + testCaseNb==(byte)0x0C || //tc 16 + testCaseNb==(byte)0x10) //tc 23 + {handler_available=false;} + + else if (testCaseNb ==(byte)0x03 || + testCaseNb ==(byte)0x0D || //tc 19 + testCaseNb ==(byte)0x11 ) //tc 24 + {handler_available=true;} + + switch (event) { + //-- tc 01 + case EVENT_FIRST_COMMAND_AFTER_ATR : + testCaseNb=(byte)0x01; + checkHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + + //-- TC 2 + case EVENT_PROFILE_DOWNLOAD: + checkHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + + + //-- TC 22 + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + try{ + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + EnvelopeHandler envHdr = EnvelopeHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb, bRes); + break; + + //-- TC 24 + case EVENT_APPLICATION_DESELECT: + checkHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + + //-- all other test cases + default : + checkHandler(); + break; + } + } + + + + + /** + * Verify if the envelope handler is available or not + */ + + private boolean checkHandler() + { + bRes=false; + //handler shall be available + if (handler_available==true){ + try { + EnvelopeHandler EnvHdr = EnvelopeHandlerSystem.getTheHandler(); + bRes=true; + } + catch (Exception e) { + bRes=false; + } + } + //handler shall not be available + else { + try { + EnvelopeHandler EnvHdr = EnvelopeHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if(exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + } + + this.reportTestOutcome(testCaseNb,bRes); + return bRes; + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_3.java new file mode 100644 index 0000000000000000000000000000000000000000..99d881aad8d0cda3f90899b88932629f7b8c173c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Cre_Mha_Enhd_3.java @@ -0,0 +1,159 @@ +//----------------------------------------------------------------------------- +// Cre_Mha_Enhd_3 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_enhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +public class Cre_Mha_Enhd_3 extends TestToolkitApplet { + /** result of specific testcase */ + boolean bRes = false; + /** result of test in install method */ + static boolean bInstallRes = false; + + /** number of testcase */ + byte testCaseNb = (byte) 0x00; +// private short eventList[] = { +// EVENT_EVENT_BROWSING_STATUS, +// EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, +// }; + + + /** + */ + private Cre_Mha_Enhd_3 () {} + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + + private byte[] baTestsResults = new byte[128]; + private byte[] baTestAppletId = new byte[17]; + + + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Enhd_3 applet = new Cre_Mha_Enhd_3(); + + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + //initialize the data of the test applet + applet.init(); + +// //register to the of the events +// applet.obReg.setEventList(applet.eventList,(short)0,(short)applet.eventList.length); + + + // - TC 1.1 (ld 25) + // - The EnvelopeHandler is not available outside the processToolkit() method + try{ + bInstallRes=false; + //get the Proactive Handler + EnvelopeHandler EnvHdr = EnvelopeHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bInstallRes=true; + } + } + + } + + public void process(APDU apdu) { + + if (selectingApplet()){ + //- TC 1.2 (ld 25) + //- The EnvelopeHandler is not available outside the processToolkit() method + if (testCaseNb==(byte)0x00){ + testCaseNb=(byte)0x01; + bRes=false; + try{ + EnvelopeHandler EnvHdr = EnvelopeHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + //bRes can be only true if the first part of test (1.1) is not failed + if (bInstallRes==true){bRes=true;} + } + } + this.reportTestOutcome(testCaseNb,bRes); + } + + + /* end of th test: result is sent to the Terminal */ + /* Construct and send the results of the tests */ + apdu.setOutgoing(); + apdu.setOutgoingLength((short)((short)(this.baTestAppletId[0] + this.baTestsResults[0]) + + (short)2)); + apdu.sendBytesLong(this.baTestAppletId, (short)0, (short)((short)(this.baTestAppletId[0]) + (short)1)); + apdu.sendBytesLong(this.baTestsResults, (short)0, (short)((short)(this.baTestsResults[0]) + (short)1)); + + } + else{ + //call the implementation from the test applet + super.process(apdu); + } + } + + + /** + * Method called to initialize the AID + */ + public void init() throws SystemException { + + // Get the AID value + this.baTestAppletId[0] = JCSystem.getAID().getBytes(this.baTestAppletId, (short)1); + Util.arrayFillNonAtomic(this.baTestsResults, (short)0, (short)this.baTestsResults.length, (byte)0x00); + } + + /** + * Method called by the test applet to report the result of each test case + * + * @param testCaseNumber test case number + * @param result true if successful, false otherwise + */ + protected void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + this.baTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + this.baTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + this.baTestsResults[testCaseNumber] = (byte)0x00; + } + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + // + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Test_Cre_Mha_Enhd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Test_Cre_Mha_Enhd.java new file mode 100644 index 0000000000000000000000000000000000000000..a584da8aa28d375f2e4043830a7376b29b2787ec --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/Test_Cre_Mha_Enhd.java @@ -0,0 +1,246 @@ + +//----------------------------------------------------------------------------- +//Test_Cre_Mha_Enhd.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_enhd; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Cre_Mha_Enhd extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/catre/cre_mha_enhd"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + /** test applet 1 class AID */ + private static String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + /** */ + private static String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + + + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + + /** + * + */ + public Test_Cre_Mha_Enhd(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + // test script + test.reset(); + test.terminalProfileSession("03010000 0102"); + + // Install Applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800C" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "01" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "03030404" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + + // test script + //TC 1 - select MF + response = test.selectFile("3F00"); + //TC 2 - send Terminal Profile except SET_EVENT_LIST,POLL_INTERVALL,SETUP_IDLE_MODE_TEXT,SET_UP_MENU + response = test.terminalProfileSession("FFFFDFD FFEFF1FEF FF0000FF FF9FFFEF" + + "03FF000 0007FE300 01"); + //TC 3 + response = test.terminalProfileSession("FFFFFFF FFEFF1FFF FF0000FF FF9FFFEF" + + "03FF000 0007FE300 01"); + response = test.envelopeMenuSelection("900102","9500"); + testresult = response.checkSw("9000"); + //TC 4 + response = test.envelopeMenuSelection("900101",""); + testresult &= response.checkSw("9000"); + //TC 5 + response = test.envelopeTimerExpiration("A40101"); + //TC 6 + response = test.envelopeCallControlByNAA(); + testresult &= response.checkSw("9000"); + //TC 7 + response = test.envelopeEventDownloadMTCall(); + testresult &= response.checkSw("9000"); + //TC 8 + response = test.envelopeEventDownloadCallConnected(); + testresult &= response.checkSw("9000"); + //TC 9 + response = test.envelopeEventDownloadCallDisconnected(); + testresult &= response.checkSw("9000"); + //TC 10 + response = test.envelopeEventDownloadLocationStatus(); + testresult &= response.checkSw("9000"); + //TC 11 + response = test.envelopeEventDownloadUserActivity(); + testresult &= response.checkSw("9000"); + //TC 12 + response = test.envelopeEventDownloadIdleScreenAvailable(); + testresult &= response.checkSw("9000"); + //TC 13 + response = test.envelopeEventDownloadCardReaderStatus(); + testresult &= response.checkSw("9000"); + //TC 14 + response = test.envelopeEventDownloadLanguageSelection(); + testresult &= response.checkSw("9000"); + //TC 15 + response = test.envelopeEventDownloadBrowserTermination(); + testresult &= response.checkSw("9000"); + //TC 16 + response = test.status("00","0C","00"); + testresult &= response.checkSw("911A"); + //TC 17 + response = test.fetch("1A"); + response = test.terminalResponse("81030140 01820282 8183010038 0281003502 " + + "03003902 000A"); + testresult &= response.checkSw("9000"); + response = test.envelopeEventDownloadDataAvailable("B8028100"); + testresult &= response.checkSw("9000"); + //TC 18 + response = test.envelopeEventDownloadChannelStatus("B8028100"); + testresult &= response.checkSw("9000"); + //TC 19 + response = test.unrecognizedEnvelope(); + response = test.fetch("10");//fetch declare service + //get the service record tlv from declare service command + String servrectlv = getServiceRecordTLV(response.getData()); + response = test.terminalResponse("81030147 0082028281 830100"); + testresult &= response.checkSw("9000"); + //TC 20 + response = test.envelopeEventDownloadLocalConnection("C1040000FFFF"); + testresult &= response.checkSw("9000"); + //TC 21 + response = test.envelopeEventDownloadAccessTechnologyChange(); + testresult &= response.checkSw("9000"); + //TC 22 + response = test.envelopeEventDownloadDisplayParametersChanged(); + testresult &= response.checkSw("9000"); + //TC 23 + //envelope handler availability with + //event proactive handler available + //TC 24 APPLICATION DESELECT + response = test.selectApplication ("A0000000 090005FF FFFFFF89 E0000002"); + response = test.sendApdu ("00A4044C 10A00000 00090005 FFFFFFFF 89E00000 02"); + testresult &= response.checkSw("9000"); + //TC 25 + response = test.envelopeEventDownloadNetworkSearchModeChange(); + testresult &= response.checkSw("9000"); + //TC 26 + response = test.envelopeEventDownloadBrowsingStatus(); + testresult &= response.checkSw("9000"); + //TC 27 + test.reset(); + response = test.terminalProfileSession("FFFFFFF FFEFF1FFF FF0000FF FF9FFFEF" + + "03FF000 0007FE300 01"); + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + response = test.selectApplication(APPLET_AID_3); + testresult &= response.checkSw("9000"); + + //CHECK TEST RESULT + response = test.selectApplication(APPLET_AID_1); + testresult &= response.checkData("10" +APPLET_AID_1 + + "1ACCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCC"); + + response = test.selectApplication(APPLET_AID_2); + testresult &= response.checkData("10" +APPLET_AID_2 + + "13CCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCC CCCC"); + + response = test.selectApplication(APPLET_AID_3); + testresult &= response.checkData("10" +APPLET_AID_3 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + /** + * Parse the service record TLV from a proactive declare service command. + * @param declareServiceCommand proactive declare service command + * @return service record TLV service record TLV + */ + public String getServiceRecordTLV(String declareServiceCommand){ + String temp = declareServiceCommand.replaceAll(" ",""); //don't bother with formatted strings + if (temp.length()>22){ + temp=temp.substring(22);//cut off BER TLV, len command details and dev id + int len = Integer.valueOf(temp.substring(2,4),16).intValue(); + if (len==temp.length()){ + return temp; + } + else{ + // suppress UICC/terminal interface TLV + return temp.substring(0,(Integer.valueOf(temp.substring(2,4),16).intValue())*2+4); + } + } + else return ""; + + } + + + + + + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..de84551f0cddf3d2fb10302790769b9a095cf806 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_mha_enhd.Cre_Mha_Enhd_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_mha_enhd.Cre_Mha_Enhd_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_mha_enhd.Cre_Mha_Enhd_1 +uicc.test.catre.cre_mha_enhd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/javacard/cre_mha_enhd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/javacard/cre_mha_enhd.cap new file mode 100644 index 0000000000000000000000000000000000000000..852e78e4607e46b384747a41690edbc66a86fb64 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_enhd/javacard/cre_mha_enhd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f484904f76c6942a3bc6cab980bf8ccb63171cd8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_1.java @@ -0,0 +1,632 @@ +//----------------------------------------------------------------------------- +//FWK_MHA_ERHD +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_erhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Erhd_1 extends TestToolkitApplet { + + /** result of specific testcase */ + private boolean bRes = false; + /** number of testcase */ + private byte testCaseNb = (byte) 0x00; +// /** nominal condition of the handlers */ +// private boolean HANDLER_AVAILABLE = true; + /** */ + private final static byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ', (byte) '1'}; + private final static byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ', (byte) '2'}; + private final static byte[] TEXT = {(byte) 'T', (byte) 'E', (byte) 'X', (byte) 'T', (byte) ' ', (byte) '1'}; + public final static byte QUALIFIER_1 = (byte) 0x01; + public final static byte[] ADDRESS_VALUE = {(byte) 0x81, (byte) 0x55, (byte) 0x66, (byte) 0x77, (byte) 0x88}; + public final static byte[] BEARER_VALUE = {(byte) 0x03, (byte) 0x00}; + public final static byte[] BUFFER_SIZE_VALUE = {(byte) 0x00, (byte) 0x01}; + protected byte service_id = (byte)0x00; + protected byte[] SERVICE_RECORD_VALUE = {(byte) 0x00, (byte) 0x00, (byte) 0x00}; + private byte triggerNr = (byte) 0x00; + private boolean bRes_old = false; + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + + /** list included registered all events */ + private short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_PROFILE_DOWNLOAD, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_CALL_CONTROL_BY_NAA, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_APPLICATION_DESELECT, + EVENT_EVENT_BROWSING_STATUS, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + }; + + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Erhd_1 applet = new Cre_Mha_Erhd_1(); + + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + + //initialize the data of the test applet + applet.init(); + + //- Applet registration + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(menuItem1,(short)0,(short)menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + applet.obReg.initMenuEntry(menuItem1,(short)0,(short)menuItem2.length,(byte)0x00,true ,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_EVENT_DOWNLLOAD_LOCAL_CONNECTION + applet.service_id = applet.obReg.allocateServiceIdentifier(); + applet.SERVICE_RECORD_VALUE[(byte)0x01]=applet.service_id; + //register to the resto of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + //register to EVENT_TIMER_EXPIRATION + for (byte timer=(byte)0x00;timer<(byte)0x08;timer++){ + applet.obReg.allocateTimer(); + } + for (byte timer=(byte)0x02;timer<=(byte)0x08;timer++){ + //release timer from 2 to 8 to be sure that only timer id 1 is allocated + applet.obReg.releaseTimer(timer); + } + + } + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)01; + + + switch(event) { + //-- TC 1 + case(EVENT_FIRST_COMMAND_AFTER_ATR): + checkHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + + //--TC 2 + case(EVENT_PROFILE_DOWNLOAD): + checkHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + + //-- TC 16 + case EVENT_STATUS_COMMAND: + try { + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch (ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + // Open Channel(1) proactive command for next test case 17 + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + proHdr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short) 0, (short) 5); + proHdr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short) 0, (short) 2); + proHdr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short) 0, (short) 2); + proHdr.send(); + bRes=true; + } + } + catch (Exception exp) { bRes = false;} + this.reportTestOutcome(testCaseNb, bRes); + break; + + //-- TC 18,20.2 + case EVENT_CALL_CONTROL_BY_NAA: + //-- TC 18.1 + if (triggerNr==(byte)0x00) {//tc is triggered the first time + try { + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + envRHdr.postAsBERTLV(true, (byte) 0x00); + //call all methods including the inherited) + bRes = isHandlerNotAvailable(envRHdr); + if(bRes) { + //next call control by naa belongs to this test also + triggerNr+=(byte)0x01; + bRes_old=bRes; + } + } + catch (Exception exp) { + bRes = false; + triggerNr+=(byte)0x01; + } + testCaseNb=(byte)(testCaseNb-(byte)0x01);//next naa trigger belongs to this test case + } + //-- TC 18.2 + else if(triggerNr==(byte)0x01) + { + try { + //if bRes_old is false the first part of test case is failed + if(bRes_old){ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + byte bArray[]= new byte[] {(byte)0x00,(byte)0x00}; + proHdr.initDisplayText((byte)0x80,(byte)0x04,bArray,(short)0,(short)bArray.length); + proHdr.send(); + //call all method of the EnvelopeResponseHandler including inherited + bRes = isHandlerNotAvailable(envRHdr); + triggerNr=(byte)0x00; + } + } + catch(Exception exp) {bRes=false;} + triggerNr=(byte)0x00; + } + //-- TC 20.2 + else if(testCaseNb==(byte)0x14){ + try{ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + envRHdr.postAsBERTLV(true,(byte)0x00); + //TC 20.1 shall be executed successfully + bRes=true; + } + catch(Exception exp){bRes=false;} + } + this.reportTestOutcome(testCaseNb, bRes); + break; //call controll by naa + + //-- TC 19,20.1,21 + case EVENT_UNRECOGNIZED_ENVELOPE: + //-- TC 19.1 + if(triggerNr==(byte)0x00){ + bRes_old=false; + testCaseNb=(byte)0x13; + try{ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + envRHdr.postAsBERTLV(true,(byte)0x00); + //Calls all methods of the handler (including the inherited methods). + bRes=isHandlerNotAvailable(envRHdr); + if(bRes){bRes_old=bRes;} + } + catch(Exception exp){ + bRes=false; + bRes_old=false; + } + testCaseNb=(byte)(testCaseNb-(byte)0x01);//next unrec. envelope trigger belongs to this case + triggerNr+=(byte)0x01; + } + //-- TC 19.2 + else if(triggerNr==(byte)0x01){ + try{ + //if bRes_old is false the first part of testcase failed + if(bRes_old){ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + + byte bArray[] = new byte[]{(byte)0x01,(byte)0x02,(byte)0x03}; + proHdr.initDisplayText((byte)0x80,(byte)0x04,bArray,(short)0,(short)bArray.length); + proHdr.send(); + //Calls all methods of the handler (including the inherited methods). + bRes=isHandlerNotAvailable(envRHdr); + } + } + catch(Exception exp){ + bRes=false; + } + triggerNr+=(byte)0x01; + this.reportTestOutcome(testCaseNb,bRes); + } + //-- TC 20.1 + //test case 20.2 will be triggered by call controll by naa + else if(triggerNr==(byte)0x02){ + bRes_old=false; + try{ + triggerNr+=(byte)0x01; + //next case triggered by call controll by NAA belongs to this test. + testCaseNb=(byte)(testCaseNb-(byte)0x01); + ProactiveHandler prHdr = ProactiveHandlerSystem.getTheHandler(); + //build a proactive command DISPLAY TEXT + prHdr.initDisplayText((byte)0x80,(byte)0x04,TEXT,(short)0,(short)TEXT.length); + //send the proactive command DISPLAY TEXT + prHdr.send(); + bRes=true; + } + catch(Exception exp){ + bRes=false; + } + + } + //-- TC 21 + else if (triggerNr==(byte)0x03){ + try{ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp){bRes=false;} + triggerNr=(byte)0x00; + this.reportTestOutcome(testCaseNb,bRes); + } + + + break; + + //-- TC 23 + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + checkHandler(); + break; + + //-- TC 24 + case EVENT_PROACTIVE_HANDLER_AVAILABLE: + try{ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + + } + catch (ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + //get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + proHdr.init(PRO_CMD_DECLARE_SERVICE, (byte)0, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_SERVICE_RECORD, SERVICE_RECORD_VALUE, (short) 0, (short) 3); + if (proHdr.send() == (byte) 0x00) { + bRes = true; + } + } + } + + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + break; + + //-- TC 25 + case EVENT_APPLICATION_DESELECT: + checkHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + + //-- TC 3,4,5,6,7,8,9,10,11,12,13,14,15, + default: + checkHandler(); + break; + + } + } + + + + + + + + /** + * Verifies if the envelope response handler is not available + * @return value of bRes + */ + private boolean checkHandler() + { + bRes=false; + try { + EnvelopeResponseHandler EnvRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp) { + if(exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + return bRes; + + } + + + + /** + * Calls all methods of the Envelope Response Handler (including the + * inherited methods). + * + * @param envRHdr EnvelopeResponseHandler + * @return true if every called method thows a ToolkitException.HANDLER_NOT_AVAILABLE. + * Otherwise it returns false + */ + boolean isHandlerNotAvailable(EnvelopeResponseHandler envRHdr) { + bRes = true; + byte bArray[] = new byte[]{(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04}; + byte buffer[] = new byte[10]; + // + // call all methods inherited from Interface EditHandler + // + //method post(boolean value) + try { + envRHdr.post(true); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //method postAsBERTLV(boolean value, byte tag).. + try { + envRHdr.postAsBERTLV(true,(byte)0x00); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendArray(byte[]buffer,short offset, short length) + try { + envRHdr.appendArray(bArray,(short)0,(short)4); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, byte value) + try { + envRHdr.appendTLV((byte)0x01,(byte)0x02); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, byte[] value, short valueOffset, short valueLength) + try { + envRHdr.appendTLV((byte)0x01,bArray,(short)0,(short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, byte[] value1, short value1Offset, short value1Length, byte[] value2, short value2Offset, short value2Length) + try { + envRHdr.appendTLV((byte)0x01,bArray,(short)0,(short)1,bArray,(short)1,(short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, byte value1, byte value2) + try { + envRHdr.appendTLV((byte)0x01,(byte)0x02,(byte)0x03); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, byte value1, byte[] value2, short value2Offset, short value2Length) + try { + envRHdr.appendTLV((byte)0x01,(byte)0x02,bArray,(short)0,(short)2); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, byte value1, short value2) + try { + envRHdr.appendTLV((byte)0x01,(byte)0x02,(short)3); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, short value) + try { + envRHdr.appendTLV((byte)0x01,(short)2); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //appendTLV(byte tag, short value1, short value2) + try { + envRHdr.appendTLV((byte)0x01,(short)2,(short)3); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //clear() + try { + envRHdr.clear(); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + // + // call all methods inherited from Interface ViewHandler + // + + //compareValue(short valueOffset, byte[] compareuffer, short compareOffset, short compareLength) + try { + envRHdr.compareValue((short)0,buffer, (short)0, (short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //copy (byte[] dstBuffer, short dstOffset, short dstLength) + try { + envRHdr.copy(buffer,(short)0,(short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //copyValue(short valueOffset, byte[] dstBuffer, short dstOffset, short dstLength) + try { + envRHdr.copyValue((short)0,buffer,(short)0,(short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //findAndCompareValue(byte tag,byte[] compareBuffer, short compareOffset) + try { + envRHdr.findAndCompareValue((byte)0x01,buffer,(short)0); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //findAndCompareValue(byte tag, byte occurence, short valueOffset, byte[] compareBuffer, short compareOffset, short compareLength) + try { + envRHdr.findAndCompareValue((byte)0x00,(byte)0x01,(short)1,buffer,(short)0,(short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //findAndCopyValue(byte tag, byte[] dstBuffer, short dstOffset) + try { + envRHdr.findAndCopyValue((byte)0x00,buffer,(short)0); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //findAndCopyValue(byte tag, byte occurence, short valueOffset, byte[] dstBuffer, short dstOffset, short dstlength) + try { + envRHdr.findAndCopyValue((byte)0x00,(byte)0x01,(short)0,buffer,(short)0,(short)1); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //findTLV(byte tag, byte occurrence) + try { + envRHdr.findTLV((byte)0x00,(byte)0x01); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //getCapacity() + try { + envRHdr.getCapacity(); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //getLength() + try { + envRHdr.getLength(); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //getValueByte(short vallueOffset) + try { + envRHdr.getValueByte((short)0); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //getValueLength + try { + envRHdr.getValueLength(); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + //getValueShort(short valueOffset) + try { + envRHdr.getValueShort((short)0); + } + catch (ToolkitException exp) { + if (exp.getReason() != ToolkitException.HANDLER_NOT_AVAILABLE) {bRes = false;} + } + catch(Exception exp) { + bRes=false; + } + + return bRes; + } + + + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_2.java new file mode 100644 index 0000000000000000000000000000000000000000..c20dec234e271ab86bc3e234d7a3ffe3fdd222ee --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_2.java @@ -0,0 +1,146 @@ +//----------------------------------------------------------------------------- +//FWK_MHA_ERHD +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_erhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Erhd_2 extends TestToolkitApplet { + + /** result of specific testcase */ + private boolean bRes = false; + /** number of testcase */ + private byte testCaseNb = (byte)0x00; + /** use for counting the triggering of the unrecognize envelope*/ + private byte triggerNr = (byte)0x00; + ; + /**stores the value of the result */ + private boolean bRes_old = false; + /** list included registered all events */ + private short eventList[] = {EVENT_UNRECOGNIZED_ENVELOPE}; + + + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Erhd_2 applet = new Cre_Mha_Erhd_2(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + //initialize the data of the test applet + applet.init(); + + //register to the resto of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)0x01; + switch (event) { + //-- TC 19.1 + case EVENT_UNRECOGNIZED_ENVELOPE: + if(triggerNr==(byte)0x00 ){//TC 19.1 + try{ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bRes=true; + } + } + bRes_old=bRes; + //next trigger belongs to this test case + triggerNr+=(byte)0x01; + testCaseNb=(byte)(testCaseNb-(byte)0x01); + } + + //-- TC 19.2 + else if(triggerNr==(byte)0x01){ +// testCaseNb=(byte)0x01; + //if bRes_old is false the first part of this test case failed + if(bRes_old){ + try{ + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bRes=true; + } + } + } + triggerNr+=(byte)0x01; + this.reportTestOutcome(testCaseNb,bRes); + } + + //-- TC 21 + else if(triggerNr==(byte)0x02) { + try{ + //set tc to 2 because tc 20 use an unrec. envelope also + testCaseNb=(byte)0x02; + EnvelopeResponseHandler envRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp){bRes=false;} + //triggerNr=(byte)0x00; + this.reportTestOutcome(testCaseNb,bRes); + } + + + break; + + default: + break; + } + } +// /** +// * If the EnvelopeResponseHandler is available, the test +// * case will be reported as successful. Otherwise as false. +// * +// * @param testCaseNb Number of current test case +// * @return @return true if the EnvelopeResponseHandler is available. +// * Otherwise false. +// */ +// boolean isHandlerNotAvailable(byte testCaseNb) { +// try { +// EnvelopeResponseHandler EnvRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); +// } +// catch(ToolkitException exp) { +// if(exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) { +// bRes=true; +// } +// } +// catch(Exception exp) {bRes=false;} +// this.reportTestOutcome(testCaseNb,bRes); +// return bRes; +// } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_3.java new file mode 100644 index 0000000000000000000000000000000000000000..e233df396cd5e29d7aa98681140ca5f35747f844 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Cre_Mha_Erhd_3.java @@ -0,0 +1,165 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Aptlbss +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_erhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +public class Cre_Mha_Erhd_3 extends TestToolkitApplet { + /** result of specific testcase */ + boolean bRes = false; + /** result of test in install method */ + static boolean bInstallRes = false; + + /** number of testcase */ + byte testCaseNb = (byte) 0x00; +// private short eventList[] = { +// EVENT_EVENT_BROWSING_STATUS, +// EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, +// }; + + /** + */ + private Cre_Mha_Erhd_3 () {} + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + + private byte[] baTestsResults = new byte[128]; + private byte[] baTestAppletId = new byte[17]; + + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Erhd_3 applet = new Cre_Mha_Erhd_3(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + //initialize the data of the test applet + applet.init(); + + //register to the resto of the events +// applet.obReg.setEventList(applet.eventList,(short)0,(short)applet.eventList.length); + + + + // - TC 1.1 (ld 27) + // - The EnvelopeResponseHandler is not available outside the processToolkit() method + try{ + bInstallRes=false; + //get the Proactive Handler + EnvelopeResponseHandler EnvRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bInstallRes=true; + } + } + } + + public void process(APDU apdu) { + if (selectingApplet()){ + //- TC 1.2 (ld 27) + //- The EnvelopeResponseHandler is not available outside the processToolkit() method + if (testCaseNb==(byte)0x00){//shall be only selected once + testCaseNb=(byte)0x01; + bRes=false; + try{ + EnvelopeResponseHandler EnvRHdr = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + //bRes can be only true if the first part of test (1.1) is not failed + if (bInstallRes==true){bRes=true;} + } + } + this.reportTestOutcome(testCaseNb,bRes); + } + + /* end of th test: result is sent to the Terminal */ + /* Construct and send the results of the tests */ + apdu.setOutgoing(); + apdu.setOutgoingLength((short)((short)(this.baTestAppletId[0] + this.baTestsResults[0]) + + (short)2)); + apdu.sendBytesLong(this.baTestAppletId, (short)0, (short)((short)(this.baTestAppletId[0]) + (short)1)); + apdu.sendBytesLong(this.baTestsResults, (short)0, (short)((short)(this.baTestsResults[0]) + (short)1)); + + } + else{ + //call the implementation from the test applet + super.process(apdu); + } + } + + + /** + * Method called to initialize the AID + */ + public void init() throws SystemException { + + // Get the AID value + this.baTestAppletId[0] = JCSystem.getAID().getBytes(this.baTestAppletId, (short)1); + Util.arrayFillNonAtomic(this.baTestsResults, (short)0, (short)this.baTestsResults.length, (byte)0x00); + } + + /** + * Method called by the test applet to report the result of each test case + * + * @param testCaseNumber test case number + * @param result true if successful, false otherwise + */ + protected void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + this.baTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + this.baTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + this.baTestsResults[testCaseNumber] = (byte)0x00; + } + } + + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + // + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Test_Cre_Mha_Erhd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Test_Cre_Mha_Erhd.java new file mode 100644 index 0000000000000000000000000000000000000000..760b4a41ec0d9fe7c5217f73ee360101a98d1ff4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/Test_Cre_Mha_Erhd.java @@ -0,0 +1,264 @@ + +//----------------------------------------------------------------------------- +//Test_Cre_Mha_Erhd.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_erhd; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Cre_Mha_Erhd extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/catre/cre_mha_erhd"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + /** test applet 1 class AID */ + private static String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + /** */ + private static String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Cre_Mha_Erhd(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + // test script + test.reset(); + test.terminalProfileSession("16FF"); + // Install Applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800C" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "01" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "03030404" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + + // test script + //TC 1 - select MF + //response = test.selectFile("3F02"); + response = test.selectFile("3F00"); + //TC 2 - send Terminal Profile except SET_EVENT_LIST,POLL_INTERVALL,SETUP_IDLE_MODE_TEXT,SET_UP_MENU + response = test.terminalProfileSession("FFFFDFDF FEFF1FEF FF0000FF FF9FFFEF" + + "03FF0000 007FE300 01"); + //TC 3 (TP with all facilities except SET_UP_EVENT_LIST) + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + response = test.envelopeMenuSelection("900102","9500"); + testresult = response.checkSw("9000"); + //TC 4 + response = test.envelopeMenuSelection("900101",""); + testresult &= response.checkSw("9000"); + //TC 5 + response = test.envelopeTimerExpiration("A40101"); + //TC 6 + response = test.envelopeEventDownloadMTCall(); + testresult &= response.checkSw("9000"); + //TC 7 + response = test.envelopeEventDownloadCallConnected(); + testresult &= response.checkSw("9000"); + //TC 8 + response = test.envelopeEventDownloadCallDisconnected(); + testresult &= response.checkSw("9000"); + //TC 9 + response = test.envelopeEventDownloadLocationStatus(); + testresult &= response.checkSw("9000"); + //TC 10 + response = test.envelopeEventDownloadUserActivity(); + testresult &= response.checkSw("9000"); + //TC 11 + response = test.envelopeEventDownloadIdleScreenAvailable(); + testresult &= response.checkSw("9000"); + //TC 12 + response = test.envelopeEventDownloadCardReaderStatus(); + testresult &= response.checkSw("9000"); + //TC 13 + response = test.envelopeEventDownloadLanguageSelection(); + testresult &= response.checkSw("9000"); + //TC 14 + response = test.envelopeEventDownloadBrowserTermination(); + testresult &= response.checkSw("9000"); + //TC 15 + response = test.status("00","0C","00"); + testresult &= response.checkSw("911A"); + //TC 16 + response = test.fetch("1A"); + response = test.terminalResponse("81030140 01820282 8183010038 0281003502 " + + "03003902 000A"); + testresult &= response.checkSw("9000"); + response = test.envelopeEventDownloadDataAvailable("B8028100");//channel id 1 + testresult &= response.checkSw("9000"); + //TC 17 + response = test.envelopeEventDownloadChannelStatus("B8028100"); + testresult &= response.checkSw("9000"); + //TC 18 + response = test.envelopeCallControlByNAA(); + testresult &= response.checkSw("9000"); + response = test.envelopeCallControlByNAA(); + testresult &= response.checkSw("9110"); + response = test.fetch("10"); + testresult &= response.checkData("D00E8103 01218082 0281028D 03040000"); + response = test.terminalResponse("81030110 00820282 81830100"); + testresult &= response.checkSw("9000"); + //TC 19 + response = test.unrecognizedEnvelope(); + testresult &= response.checkSw("9000"); + response = test.unrecognizedEnvelope(); + testresult &= response.checkSw("9111"); + response = test.fetch("11"); + testresult &= response.checkData("D00F8103 01218082 0281028D 0404010203"); + response = test.terminalResponse("81030110 00820282 81830100"); + testresult &= response.checkSw("9000"); + //TC 20 + response = test.unrecognizedEnvelope(); + testresult &= response.checkSw("9114"); + response = test.envelopeCallControlByNAA(); + testresult &= response.checkSw("9114"); + response = test.fetch("14"); + testresult &= response.checkData("D0128103 01218082 0281028D 07045445 58542031"); + response = test.terminalResponse("81030121 80820282 81030100"); + testresult &= response.checkSw("9000"); + //TC 21 + response = test.unrecognizedEnvelope(); + testresult &= response.checkSw("9000"); + //TC 22 + response = test.envelopeEventDownloadAccessTechnologyChange(); + testresult &= response.checkSw("9000"); + //TC 23 + response = test.envelopeEventDownloadDisplayParametersChanged(); + testresult &= response.checkSw("9110"); + //TC 24 + //fetch declare service + response = test.fetch("10");//fetch declare service + //get the service record tlv from declare service command + String servrectlv = getServiceRecordTLV(response.getData()); + response = test.terminalResponse("81030147 0082028281 830100"); + testresult &= response.checkSw("9000"); + //TC 25 + response = test.envelopeEventDownloadLocalConnection("C1040000FFFF"); + testresult &= response.checkSw("9000"); + //TC 26 + response = test.selectApplication ("A0000000 090005FF FFFFFF89 E0000002"); + response = test.sendApdu ("00A4044C 10A00000 00090005 FFFFFFFF 89E00000 02"); + testresult &= response.checkSw("9000"); + //TC 27 + response = test.envelopeEventDownloadNetworkSearchModeChange(); + testresult &= response.checkSw("9000"); + //TC 28 + response = test.envelopeEventDownloadBrowsingStatus(); + testresult &= response.checkSw("9000"); + //TC 27 + test.reset(); + response = test.terminalProfileSession("13"); + + //test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + response = test.selectApplication(APPLET_AID_3); + +// test.reset(); +// response = test.terminalProfileSession("13"); + + + //check results of the tests + //test.reset(); + response = test.selectApplication(APPLET_AID_1); + testresult &= response.checkData("10" +APPLET_AID_1 + + "1CCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CC"); + + response = test.selectApplication(APPLET_AID_2); + testresult &= response.checkData("10" +APPLET_AID_2 + + "02CCCC"); + + response = test.selectApplication(APPLET_AID_3); + testresult &= response.checkData("10" +APPLET_AID_3 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + + /** + * Parse the service record TLV from a proactive declare service command. + * @param declareServiceCommand proactive declare service command + * @return service record TLV service record TLV + */ + public String getServiceRecordTLV(String declareServiceCommand){ + String temp = declareServiceCommand.replaceAll(" ",""); //don't bother with formatted strings + if (temp.length()>22){ + temp=temp.substring(22);//cut off BER TLV, len command details and dev id + int len = Integer.valueOf(temp.substring(2,4),16).intValue(); + if (len==temp.length()){ + return temp; + } + else{ + // suppress UICC/terminal interface TLV + return temp.substring(0,(Integer.valueOf(temp.substring(2,4),16).intValue())*2+4); + } + } + else return ""; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..be3c7610184f1af2c4c974f5ff6359582d733c2c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_mha_erhd.Cre_Mha_Erhd_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_mha_erhd.Cre_Mha_Erhd_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_mha_erhd.Cre_Mha_Erhd_1 +uicc.test.catre.cre_mha_erhd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/javacard/cre_mha_erhd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/javacard/cre_mha_erhd.cap new file mode 100644 index 0000000000000000000000000000000000000000..03e688201b1bf3686e39a47cd3f7893400bdb850 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_erhd/javacard/cre_mha_erhd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..194ea6679bb5d2ec5b283347786fa92c9acfa1d5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_1.java @@ -0,0 +1,265 @@ +//----------------------------------------------------------------------------- +//Cre_Mha_Pahd +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_pahd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Pahd_1 extends TestToolkitApplet { + + /** result of specific testcase */ + boolean bRes = false; + + + /** number of testcase */ + byte testCaseNb = (byte) 0x00; + /** */ + boolean handler_available = true; + private final byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '1'}; + private final byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '2'}; + private final byte QUALIFIER_1 = (byte) 0x01; + private final byte[] ADDRESS_VALUE = {(byte) 0x81, (byte) 0x55, (byte) 0x66, (byte) 0x77, (byte) 0x88}; + private final byte[] BEARER_VALUE = {(byte) 0x03, (byte) 0x00}; + private final byte[] BUFFER_SIZE_VALUE = {(byte) 0x00, (byte) 0x01}; + protected byte service_id = (byte)0x00; + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + // Technology independet,servicenr. 0, service record: 00 00 + protected byte[] SERVICE_RECORD_VALUE = {(byte)0x00,(byte)0x00,(byte)0x00}; + + private final short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_CALL_CONTROL_BY_NAA, + EVENT_PROFILE_DOWNLOAD, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + EVENT_EVENT_BROWSING_STATUS, + EVENT_APPLICATION_DESELECT + }; + + + + + /** + */ + private Cre_Mha_Pahd_1 () {} + + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + + + + Cre_Mha_Pahd_1 applet = new Cre_Mha_Pahd_1(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + //initalise all values of the TestToolkitApplet + applet.init(); + + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + applet.obReg.initMenuEntry(applet.menuItem2,(short)0,(short)applet.menuItem2.length,(byte)0x00,true ,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_EVENT_DOWNLLOAD_LOCAL_CONNECTION + applet.service_id = applet.obReg.allocateServiceIdentifier(); + //store the allocated service id + applet.SERVICE_RECORD_VALUE[(byte)0x01]=applet.service_id; + //register to the rest of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + //register to EVENT_TIMER_EXPIRATION + for (byte timer=(byte)0x00;timer<(byte)0x08;timer++){ + applet.obReg.allocateTimer(); + } + for (byte timer=(byte)0x02;timer<=(byte)0x08;timer++){ + //release timer from 2 to 8 to be sure that only timer id 1 is allocated + applet.obReg.releaseTimer(timer); + } + + } + + /* + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)0x01; + + if (testCaseNb==(byte)0x01|| + testCaseNb==(byte)0x18) {handler_available=false;} + + else if (testCaseNb==(byte)0x02 || + testCaseNb==(byte)0x2C ){handler_available=true;} + + switch(event){ + //--TC 1 + case EVENT_FIRST_COMMAND_AFTER_ATR: + testCaseNb=(byte)0x01; + checkProactiveHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + //--TC 2 + case EVENT_PROFILE_DOWNLOAD: + checkProactiveHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + + //--TC 8,23,30, + case EVENT_EVENT_DOWNLOAD_CALL_CONNECTED: + + if (testCaseNb!=(byte)0x17)checkProactiveHandler(); + else if (testCaseNb==(byte)0x17){ + //tc shall be set afterwards by triggering proactive handler available + testCaseNb=(byte)0x16;//set tc back to nr.23 + //register to event + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + } + break; + //--TC 16 + case EVENT_STATUS_COMMAND: + if (testCaseNb==(byte)0x10) { + checkProactiveHandler();//check if the proactive handler is available + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + // Open channel(1) proactive command for test case 17 ( + proHdr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + proHdr.send(); + } + else { + checkProactiveHandler(); + } + break; + + //--TC 21,41 + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + if(testCaseNb==(byte)0x15) { + try { + //get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + proHdr.init(PRO_CMD_DECLARE_SERVICE, (byte)0, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_SERVICE_RECORD, SERVICE_RECORD_VALUE, (short) 0, (short) 3); + if (proHdr.send() == (byte) 0x00) { + bRes = true; + } + } + catch (Exception exp) { + bRes = false; + } + } + else if (testCaseNb==(byte)0x29){ + try { + //get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp) { + //register to EVENT_PROACTIVE_HANDLER AVAILABLE + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + break; + + //--TC 24 + case EVENT_APPLICATION_DESELECT: + checkProactiveHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + + //--TC 43,45 + case EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE: + checkProactiveHandler(); + if(testCaseNb==(byte)0x2A) { + obReg.clearEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + //handler shall not be available + } + break; + + //- TC 3,4,5,6,7,9,10,11,12 + // 13,14,15,17,18,19,20,22 <-handler available + // 24,25,26,27,28,29,31,32,33,34,35,36,37 + // 38,39,40, + default: + checkProactiveHandler(); + break; + } + } + + + /** + * Verify if the proactive handler is available or not + */ + private void checkProactiveHandler(){ + bRes=false; + + //handler shall be available + if (handler_available==true){ + try { + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp) {bRes=false;} + } + + //handler shall not be available + else{ + try { + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch (ToolkitException e) { + if (e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + } + this.reportTestOutcome(testCaseNb,bRes); + } + + + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_2.java new file mode 100644 index 0000000000000000000000000000000000000000..53451e7d8b7549b43cbb82a145ee3989c1a4fa1b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_2.java @@ -0,0 +1,227 @@ +//----------------------------------------------------------------------------- +//Cre_Mha_Pahd +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_pahd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +public class Cre_Mha_Pahd_2 extends TestToolkitApplet { + /** result of specific testcase */ + boolean bRes = false; + + boolean handler_available = true; + /** number of testcase */ + byte testCaseNb = (byte) 0x00; + private final byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '1'}; +// private final byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '2'}; + private byte[] TEXT = {(byte)'T',(byte)'E',(byte)'X',(byte)'T',(byte)' ',(byte)'1'}; + + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + + private short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_PROFILE_DOWNLOAD, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + EVENT_EVENT_BROWSING_STATUS, + EVENT_APPLICATION_DESELECT + }; + + + /** + */ + private Cre_Mha_Pahd_2 () {} + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Pahd_2 applet = new Cre_Mha_Pahd_2(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + applet.init(); + + //- Applet registration + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_TIMER_EXPIRATION + applet.obReg.allocateTimer(); + //register to EVENT_EVENT_DOWNLLOAD_LOCAL_CONNECTION + applet.obReg.allocateServiceIdentifier(); + //register to the resto of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)applet.eventList.length); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + } + + + /* + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)0x01; + + if (testCaseNb==(byte)0x01|| + testCaseNb==(byte)0x11 ){handler_available=false;} + + else if (testCaseNb==(byte)0x02 || + testCaseNb==(byte)0x21){handler_available=true;} + + + switch (event) { + // -- TC 1 + case EVENT_FIRST_COMMAND_AFTER_ATR: + testCaseNb=(byte)0x01; + checkProactiveHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + // -- TC 2 + case EVENT_PROFILE_DOWNLOAD: + checkProactiveHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + + case EVENT_EVENT_DOWNLOAD_CALL_CONNECTED: + if (testCaseNb == (byte) 0x10) { + try { + // test case will be finished on triggering EVENT_PROACTIVE_HANDLER_AVAILABE + testCaseNb=(byte)0x0F; + // register to event + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + // get the Proactive Handler + ProactiveHandler prHdr = ProactiveHandlerSystem.getTheHandler(); + // build a proactive command DISPLAY TEXT + prHdr.initDisplayText((byte) 0x80, (byte) 0x04, TEXT, (short) 0, (short) TEXT.length); + // send the proactive command DISPLAY TEXT + prHdr.send(); + + bRes = true; + } + catch (Exception e) { + bRes = false; + this.reportTestOutcome(testCaseNb, bRes); + } + } + else { + checkProactiveHandler(); + } + break; + + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + + if (testCaseNb == (byte) 0x1E) {//TC30 + try { + // get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch (ToolkitException exp) { + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes = true; + } + this.reportTestOutcome(testCaseNb, bRes); + } + else{ + checkProactiveHandler(); + } + break; + //--TC 24 + case EVENT_APPLICATION_DESELECT: + checkProactiveHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + //--TC 43,45 + case EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE: + checkProactiveHandler(); + if(testCaseNb==(byte)0x1F) { + obReg.clearEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + } + break; + + default: + //TC 7,8,9,10,11,12,13,14,15,16,16,20,21,23,29, + //30,31,33,34,35,36,37,38,39,40,41, + checkProactiveHandler(); + break; + + } + } + + + + + + /** + * Verify if the proactive handler is available or not + */ + private void checkProactiveHandler(){ + bRes=false; + + //handler shall be available + if (handler_available==true){ + try { + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp) {bRes=false;} + } + + + //handler shall not be available + else{ + try { + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch (ToolkitException e) { + if (e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + } + this.reportTestOutcome(testCaseNb,bRes); + } + + + + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_3.java new file mode 100644 index 0000000000000000000000000000000000000000..323b8a1db9ad4940c7aa2c6f2de23df10b5552a4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Cre_Mha_Pahd_3.java @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------------- +//Cre_Mha_Pahd +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_pahd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +public class Cre_Mha_Pahd_3 extends TestToolkitApplet { + /** result of specific testcase */ + boolean bRes = false; + /** result of test in install method */ + static boolean bIRes = false; + + /** number of testcase */ + byte testCaseNb = (byte) 0x00; +// private short eventList[] = { +// EVENT_EVENT_BROWSING_STATUS, +// EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, +// EVENT_PROACTIVE_HANDLER_AVAILABLE +// }; + + + /** + */ + private Cre_Mha_Pahd_3 () {} + + + private byte[] baTestsResults = new byte[128]; + private byte[] baTestAppletId = new byte[17]; + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Pahd_3 applet = new Cre_Mha_Pahd_3(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + applet.init(); + + //register to the resto of the events +// applet.obReg.setEventList(applet.eventList,(short)0,(short)applet.eventList.length); + + + // - TC 1.1 (ld 43) + // - The ProactiveHandler is not available outside the processToolkit() method + try{ + bIRes=false; + //get the Proactive Handler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bIRes=true; + } + } + + } + + public void process(APDU apdu) { + if (selectingApplet()){ + //- TC 1.2 (ld 43) + //- The ProactiveHandler is not available outside the processToolkit() method + if (testCaseNb==(byte)0x00){ + testCaseNb=(byte)0x01; + bRes=false; + try{ + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + //bRes can be only true if the first part of test (1.1) is not failed + if (bIRes==true){bRes=true;} + } + } + this.reportTestOutcome(testCaseNb,bRes); + } + + /* end of th test: result is sent to the Terminal */ + /* Construct and send the results of the tests */ + apdu.setOutgoing(); + apdu.setOutgoingLength((short)((short)(this.baTestAppletId[0] + this.baTestsResults[0]) + + (short)2)); + apdu.sendBytesLong(this.baTestAppletId, (short)0, (short)((short)(this.baTestAppletId[0]) + (short)1)); + apdu.sendBytesLong(this.baTestsResults, (short)0, (short)((short)(this.baTestsResults[0]) + (short)1)); + } + else{ + //call the implementation from the test applet + super.process(apdu); + } + } + + + + /** + * Method called to initialize the AID + */ + public void init() throws SystemException { + + // Get the AID value + this.baTestAppletId[0] = JCSystem.getAID().getBytes(this.baTestAppletId, (short)1); + Util.arrayFillNonAtomic(this.baTestsResults, (short)0, (short)this.baTestsResults.length, (byte)0x00); + } + + /** + * Method called by the test applet to report the result of each test case + * + * @param testCaseNumber test case number + * @param result true if successful, false otherwise + */ + protected void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + this.baTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + this.baTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + this.baTestsResults[testCaseNumber] = (byte)0x00; + } + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + // + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Test_Cre_Mha_Pahd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Test_Cre_Mha_Pahd.java new file mode 100644 index 0000000000000000000000000000000000000000..98e5bfc0b5a174adb29ed0dcf1dc92301963ad02 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/Test_Cre_Mha_Pahd.java @@ -0,0 +1,337 @@ +//----------------------------------------------------------------------------- +//Test_Cre_Mha_Pahd +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_pahd; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +public class Test_Cre_Mha_Pahd extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/catre/cre_mha_pahd"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + /** test applet 1 class AID */ + private static String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + /** */ + private static String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 F0"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + public final byte[] AID_ADF1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, + (byte)0xE0, (byte)0x00, (byte)0x00, (byte)0x02}; + + + + /** + * + */ + public Test_Cre_Mha_Pahd(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + // test script + test.reset(); + test.terminalProfileSession("03010000 0102"); + + // Install Applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800C" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "01" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "03030404" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + test.reset(); + //TC 1 - select MF + response = test.selectFile("3F00"); + //TC 2 - send Terminal Profile except SET_EVENT_LIST,POLL_INTERVALL,SETUP_IDLE_MODE_TEXT,SET_UP_MENU + response = test.terminalProfileSession("FFFFDFD FFEFF1FEF FF0000FF FF9FFFEF" + + "03FF000 0007FE300 01"); + //TC 3 - initialization with all the facilities supported (without SETUP_EVENT_LIST + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + response = test.envelopeMenuSelection("900102","9500"); + testresult = response.checkSw("9000"); + //TC 4 + response = test.envelopeMenuSelection("900101",""); + testresult &= response.checkSw("9000"); + //TC 5 + response = test.envelopeTimerExpiration("A40101"); + //TC 6 + response = test.envelopeCallControlByNAA(); + testresult &= response.checkSw("9000"); + //TC 7 + response = test.envelopeEventDownloadMTCall(); + testresult &= response.checkSw("9000"); + //TC 8 + response = test.envelopeEventDownloadCallConnected(); + testresult &= response.checkSw("9000"); + //TC 9 + response = test.envelopeEventDownloadCallDisconnected(); + testresult &= response.checkSw("9000"); + //TC 10 + response = test.envelopeEventDownloadLocationStatus(); + testresult &= response.checkSw("9000"); + //TC 11 + response = test.envelopeEventDownloadUserActivity(); + testresult &= response.checkSw("9000"); + //TC 12 + response = test.envelopeEventDownloadIdleScreenAvailable(); + testresult &= response.checkSw("9000"); + //TC 13 + response = test.envelopeEventDownloadCardReaderStatus(); + testresult &= response.checkSw("9000"); + //TC 14 + response = test.envelopeEventDownloadLanguageSelection(); + testresult &= response.checkSw("9000"); + //TC 15 + response = test.envelopeEventDownloadBrowserTermination(); + testresult &= response.checkSw("9000"); + //TC 16 + response = test.status("00","0C","00"); + testresult &= response.checkSw("911A"); + //TC 17 + response = test.fetch("1A"); + response = test.terminalResponse("81030140 01820282 8183010038 0281003502 " + + "03003902 000A"); + testresult &= response.checkSw("9000"); + response = test.envelopeEventDownloadDataAvailable("B8028100"); + testresult &= response.checkSw("9000"); + //TC 18 + response = test.envelopeEventDownloadChannelStatus("B8028100"); + testresult &= response.checkSw("9000"); + //TC 19 + response = test.unrecognizedEnvelope(); + testresult &= response.checkSw("9000"); + //TC 20 + response = test.envelopeEventDownloadAccessTechnologyChange(); + testresult &= response.checkSw("9000"); + //TC 21 + response = test.envelopeEventDownloadDisplayParametersChanged(); + //fetch declare service + response = test.fetch("10"); + //get the service record tlv from declare service command + String servrectlv = getServiceRecordTLV(response.getData()); + response = test.terminalResponse("81030147 0082028281 830100"); + testresult &= response.checkSw("9000"); + //TC 22 + response = test.envelopeEventDownloadLocalConnection(servrectlv); + testresult &= response.checkSw("9000"); + //TC 23 + response = test.envelopeEventDownloadCallConnected(); + //fetch display text + response = test.fetch("14"); + response = test.terminalResponse("81030121 80820282 81030100"); + testresult &= response.checkSw("9000"); + //TC 24 + //- Select for activation ADF1 + response = test.selectApplication (byteArrayToHexString(AID_ADF1)); + //- Select for termination ADF1 + response = test.sendApdu ("00A4044C 10"+byteArrayToHexString(AID_ADF1) ); + testresult &= response.checkSw("9000"); + //TC 25 + test.reset(); + //no terminal profile is sent and proactive handler shall not be available. + response = test.envelopeMenuSelection("900102","9500"); + //TC 26 + response = test.envelopeMenuSelection("900101",""); + //TC 27 + response = test.envelopeTimerExpiration("A40101"); + //TC 28 + response = test.envelopeCallControlByNAA(); + //TC 29 + response = test.envelopeEventDownloadMTCall(); + //TC 30 + response = test.envelopeEventDownloadCallConnected(); + //TC 31 + response = test.envelopeEventDownloadCallDisconnected(); + //TC 32 + response = test.envelopeEventDownloadLocationStatus(); + //TC 33 + response = test.envelopeEventDownloadUserActivity(); + //TC 34 + response = test.envelopeEventDownloadIdleScreenAvailable(); + //TC 35 + response = test.envelopeEventDownloadCardReaderStatus(); + //TC 36 + response = test.envelopeEventDownloadLanguageSelection(); + //TC 37 + response = test.envelopeEventDownloadBrowserTermination(); + //TC 38 + response = test.status("00","0C","00"); + //TC 39 + response = test.unrecognizedEnvelope(); + //TC 40 + response = test.envelopeEventDownloadAccessTechnologyChange(); + //TC 41 + response = test.envelopeEventDownloadDisplayParametersChanged(); + //TC 42 + //The Proactive Handler is not available before the + //Terminal Profile + //TC 43 + response = test.envelopeEventDownloadNetworkSearchModeChange(); + //TC 44 + response = test.envelopeEventDownloadBrowsingStatus(); + //TC 45 + test.reset(); + //initialization with all the facilities supported (without SETUP_EVENT_LIST) + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + response = test.envelopeEventDownloadNetworkSearchModeChange(); + testresult &= response.checkSw("9000"); + //TC 46 + response = test.envelopeEventDownloadBrowsingStatus(); + testresult &= response.checkSw("9000"); + //TC 47 + test.reset(); + // Install Applet + //initialization with all the facilities supported (without SETUP_EVENT_LIST) + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + response = test.selectApplication(APPLET_AID_3); + + + // get result from applets + test.reset(); + // It is possible, based on implemenation of the card manufacturer, in + // case that a CAT facility is not supported by the terminal profile, + // the applet will not be triggered on an unsupported event. + response = test.selectApplication(APPLET_AID_1); + testresult &= (response.checkData("10" +APPLET_AID_1 + + "2DCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCC") || + response.checkData("10" +APPLET_AID_1 + + "18CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CC") ); + + response = test.selectApplication(APPLET_AID_2); + testresult &= (response.checkData("10" +APPLET_AID_2 + + "22CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCC") || + response.checkData("10" +APPLET_AID_2 + + "11CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC " + + "CCCC") ); + + response = test.selectApplication(APPLET_AID_3); + testresult &= response.checkData("10" +APPLET_AID_3 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + /** + * Converts a byte array to a hex string + * @param byteArray byte array[] + * @return the byte array as hex string:
+ * E.g: byteArray{(byte)0x11,(byte)0x22,(byte)0x33} will be returned + * as String "112233" + */ + private String byteArrayToHexString(byte[] byteArray){ + StringBuffer stringBuffer = new StringBuffer(); + for(int i=0; i22){ + temp=temp.substring(22);//cut off BER TLV, len command details and dev id + int len = Integer.valueOf(temp.substring(2,4),16).intValue(); + if (len==temp.length()){ + return temp; + } + else{ + // suppress UICC/terminal interface TLV + return temp.substring(0,(Integer.valueOf(temp.substring(2,4),16).intValue())*2+4); + } + } + else return ""; + + } + + + + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..73d39ec35a64f851c72ba0c90795a43ea31d4d43 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_mha_pahd.Cre_Mha_Pahd_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_mha_pahd.Cre_Mha_Pahd_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_mha_pahd.Cre_Mha_Pahd_1 +uicc.test.catre.cre_mha_pahd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/javacard/cre_mha_pahd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/javacard/cre_mha_pahd.cap new file mode 100644 index 0000000000000000000000000000000000000000..d5084ed561546e56794f10ca2261fe703d5d5955 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_pahd/javacard/cre_mha_pahd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..35daf04c2515de2c1dccfd117812e1e2392371a2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_1.java @@ -0,0 +1,272 @@ +//----------------------------------------------------------------------------- +// CAT_RE.CRE_MHA_PRHD +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_prhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Prhd_1 extends TestToolkitApplet { + + /* + /** result of specific testcase */ + boolean bRes = false; + + + /** number of testcase */ + byte testCaseNb = (byte) 0x00; + /** */ + boolean handler_available = true; + private final byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '1'}; + private final byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '2'}; + private final byte QUALIFIER_1 = (byte) 0x01; + private final byte[] ADDRESS_VALUE = {(byte) 0x81, (byte) 0x55, (byte) 0x66, (byte) 0x77, (byte) 0x88}; + private final byte[] BEARER_VALUE = {(byte) 0x03, (byte) 0x00}; + private final byte[] BUFFER_SIZE_VALUE = {(byte) 0x00, (byte) 0x01}; + protected byte service_id = (byte)0x00; + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + // Technology independet,servicenr. 0, service record: 00 00 + protected byte[] SERVICE_RECORD_VALUE = {(byte)0x00,(byte)0x00,(byte)0x00}; + + private final short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_CALL_CONTROL_BY_NAA, + EVENT_PROFILE_DOWNLOAD, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + EVENT_EVENT_BROWSING_STATUS, + EVENT_APPLICATION_DESELECT + }; + + + + + /** + */ + private Cre_Mha_Prhd_1 () {} + + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + + + Cre_Mha_Prhd_1 applet = new Cre_Mha_Prhd_1(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + //initalise all values of the TestToolkitApplet + applet.init(); + + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_MENU_SELECTION_HELP_REQUEST + applet.obReg.initMenuEntry(applet.menuItem2,(short)0,(short)applet.menuItem2.length,(byte)0x00,true ,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_EVENT_DOWNLLOAD_LOCAL_CONNECTION + applet.service_id = applet.obReg.allocateServiceIdentifier(); + //store the allocated service id + applet.SERVICE_RECORD_VALUE[(byte)0x01]=applet.service_id; + //register to the rest of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + //register to EVENT_TIMER_EXPIRATION + for (byte timer=(byte)0x00;timer<(byte)0x08;timer++){ + applet.obReg.allocateTimer(); + } + for (byte timer=(byte)0x02;timer<=(byte)0x08;timer++){ + //release timer from 2 to 8 to be sure that only timer id 1 is allocated + applet.obReg.releaseTimer(timer); + } + + } + + /* + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)0x01; + + if (testCaseNb==(byte)0x01|| + testCaseNb==(byte)0x18) {handler_available=false;} + + else if (testCaseNb==(byte)0x02 || + testCaseNb==(byte)0x2C ){handler_available=true;} + + switch(event){ + //--TC 1 + case EVENT_FIRST_COMMAND_AFTER_ATR: + + testCaseNb=(byte)0x01; + checkProactiveHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + //--TC 2 + case EVENT_PROFILE_DOWNLOAD: + + checkProactiveHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + + //--TC 8,23,30, + case EVENT_EVENT_DOWNLOAD_CALL_CONNECTED: + + if (testCaseNb!=(byte)0x17)checkProactiveHandler(); + else if (testCaseNb==(byte)0x17){ + //tc shall be set afterwards by triggering proactive handler available + testCaseNb=(byte)0x16;//set tc back to nr.23 + //register to event + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + } + break; + //--TC 16 + case EVENT_STATUS_COMMAND: + + if (testCaseNb==(byte)0x10) { + checkProactiveHandler();//check if the proactive handler is available + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + // Open channel(1) proactive command for test case 17 ( + proHdr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + proHdr.send(); + } + else { + checkProactiveHandler(); + } + break; + + //--TC 21,41 + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + + if(testCaseNb==(byte)0x15) { + try { + //get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + proHdr.init(PRO_CMD_DECLARE_SERVICE, (byte)0, DEV_ID_TERMINAL); + proHdr.appendTLV(TAG_SERVICE_RECORD, SERVICE_RECORD_VALUE, (short) 0, (short) 3); + if (proHdr.send() == (byte) 0x00) { + bRes = true; + } + } + catch (Exception exp) { + bRes = false; + } + } + else if (testCaseNb==(byte)0x29){ + try { + //get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp) { + //register to EVENT_PROACTIVE_HANDLER AVAILABLE + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + break; + + //--TC 24 + case EVENT_APPLICATION_DESELECT: + + checkProactiveHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + + //--TC 43,45 + case EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE: + + checkProactiveHandler(); + if(testCaseNb==(byte)0x2A) { + obReg.clearEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + //handler shall not be available + } + break; + + //- TC 3,4,5,6,7,9,10,11,12 + // 13,14,15,17,18,19,20,22 <-handler available + // 24,25,26,27,28,29,31,32,33,34,35,36,37 + // 38,39,40, + default: + checkProactiveHandler(); + break; + } + } + + + /** + * Verify if the proactive response handler is available or not + */ + private void checkProactiveHandler() + { + bRes=false; + + //handler shall be available + if (handler_available==true){ + try { + ProactiveResponseHandler proHdr = ProactiveResponseHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp) {bRes=false;} + } + + //handler shall not be available + else{ + try { + ProactiveResponseHandler proHdr = ProactiveResponseHandlerSystem.getTheHandler(); + } + catch (ToolkitException e) { + if (e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + } + this.reportTestOutcome(testCaseNb,bRes); + } + + + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_2.java new file mode 100644 index 0000000000000000000000000000000000000000..48f7b6351c257a0268c23e1292fc2a0172a6e183 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_2.java @@ -0,0 +1,224 @@ +//----------------------------------------------------------------------------- +// CAT_RE.CRE_MHA_PRHD +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_prhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Prhd_2 extends TestToolkitApplet { + boolean bRes = false; + + boolean handler_available = true; + /** number of testcase */ + byte testCaseNb = (byte) 0x00; + private final byte[] menuItem1 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '1'}; +// private final byte[] menuItem2 = {(byte) 'I', (byte) 't', (byte) 'e', (byte) 'm', (byte) ' ',(byte) '2'}; + private byte[] TEXT = {(byte)'T',(byte)'E',(byte)'X',(byte)'T',(byte)' ',(byte)'1'}; + + protected final byte[] fileEFtaru = new byte[]{ (byte) 0x01, (byte) 0x3F, (byte) 0x00, (byte) 0x7F, (byte) 0x4A,(byte) 0x6F, (byte) 0x03 }; + + private short eventList[] = { + EVENT_EVENT_DOWNLOAD_MT_CALL, + EVENT_EVENT_DOWNLOAD_CALL_CONNECTED, + EVENT_EVENT_DOWNLOAD_CALL_DISCONNECTED, + EVENT_EVENT_DOWNLOAD_LOCATION_STATUS, + EVENT_EVENT_DOWNLOAD_USER_ACTIVITY, + EVENT_EVENT_DOWNLOAD_IDLE_SCREEN_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CARD_READER_STATUS, + EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION, + EVENT_EVENT_DOWNLOAD_BROWSER_TERMINATION, + EVENT_UNRECOGNIZED_ENVELOPE, + EVENT_PROFILE_DOWNLOAD, + EVENT_FIRST_COMMAND_AFTER_ATR, + EVENT_EVENT_DOWNLOAD_DATA_AVAILABLE, + EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS, + EVENT_EVENT_DOWNLOAD_ACCESS_TECHNOLOGY_CHANGE, + EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED, + EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, + EVENT_EVENT_BROWSING_STATUS, + EVENT_APPLICATION_DESELECT + }; + + + /** + */ + private Cre_Mha_Prhd_2 () {} + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Prhd_2 applet = new Cre_Mha_Prhd_2(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + applet.init(); + + //- Applet registration + //register to EVENT_MENU_SELECTION + applet.obReg.initMenuEntry(applet.menuItem1,(short)0,(short)applet.menuItem1.length,(byte)0x00,false,(byte)0x00,(short)0); + //register to EVENT_STATUS_COMMAND + applet.obReg.requestPollInterval((short)1); + //register to EVENT_TIMER_EXPIRATION + applet.obReg.allocateTimer(); + //register to EVENT_EVENT_DOWNLLOAD_LOCAL_CONNECTION + applet.obReg.allocateServiceIdentifier(); + //register to the resto of the events + applet.obReg.setEventList(applet.eventList,(short)0,(short)applet.eventList.length); + //register to file EF_TARU + applet.obReg.registerFileEvent( EVENT_EXTERNAL_FILE_UPDATE,applet.fileEFtaru,(short) 0,(short) applet.fileEFtaru.length, null, (short) 0, (byte)0x00); + } + + + /* + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + testCaseNb+=(byte)0x01; + + if (testCaseNb==(byte)0x01|| + testCaseNb==(byte)0x11 ){handler_available=false;} + + else if (testCaseNb==(byte)0x02 || + testCaseNb==(byte)0x21){handler_available=true;} + + + switch (event) { + // -- TC 1 + case EVENT_FIRST_COMMAND_AFTER_ATR: + testCaseNb=(byte)0x01; + checkProactiveHandler(); + obReg.clearEvent(EVENT_FIRST_COMMAND_AFTER_ATR); + break; + // -- TC 2 + case EVENT_PROFILE_DOWNLOAD: + checkProactiveHandler(); + obReg.clearEvent(EVENT_PROFILE_DOWNLOAD); + break; + + case EVENT_EVENT_DOWNLOAD_CALL_CONNECTED: + if (testCaseNb == (byte) 0x10) { + try { + // test case will be finished on triggering EVENT_PROACTIVE_HANDLER_AVAILABE + testCaseNb=(byte)0x0F; + // register to event + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + // get the Proactive Handler + ProactiveHandler prHdr = ProactiveHandlerSystem.getTheHandler(); + // build a proactive command DISPLAY TEXT + prHdr.initDisplayText((byte) 0x80, (byte) 0x04, TEXT, (short) 0, (short) TEXT.length); + // send the proactive command DISPLAY TEXT + prHdr.send(); + + bRes = true; + } + catch (Exception e) { + bRes = false; + this.reportTestOutcome(testCaseNb, bRes); + } + } + else { + checkProactiveHandler(); + } + break; + + case EVENT_EVENT_DOWNLOAD_DISPLAY_PARAMETER_CHANGED: + + if (testCaseNb == (byte) 0x1E) {//TC30 + try { + // get the ProactiveHandler + ProactiveHandler proHdr = ProactiveHandlerSystem.getTheHandler(); + } + catch (ToolkitException exp) { + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + bRes = true; + } + this.reportTestOutcome(testCaseNb, bRes); + } + else{ + checkProactiveHandler(); + } + break; + //--TC 24 + case EVENT_APPLICATION_DESELECT: + checkProactiveHandler(); + obReg.clearEvent(EVENT_APPLICATION_DESELECT); + break; + //--TC 43,45 + case EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE: + checkProactiveHandler(); + if(testCaseNb==(byte)0x1F) { + obReg.clearEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + } + break; + + default: + //TC 7,8,9,10,11,12,13,14,15,16,16,20,21,23,29, + //30,31,33,34,35,36,37,38,39,40,41, + checkProactiveHandler(); + break; + + } + } + + + + + + /** + * Verify if the proactive handler is available or not + */ + private void checkProactiveHandler(){ + bRes=false; + + //handler shall be available + if (handler_available==true){ + try { + ProactiveResponseHandler proHdr = ProactiveResponseHandlerSystem.getTheHandler(); + bRes=true; + } + catch(Exception exp) {bRes=false;} + } + + + //handler shall not be available + else{ + try { + ProactiveResponseHandler proHdr = ProactiveResponseHandlerSystem.getTheHandler(); + } + catch (ToolkitException e) { + if (e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes=true; + } + } + catch(Exception exp) {bRes=false;} + } + this.reportTestOutcome(testCaseNb,bRes); + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_3.java new file mode 100644 index 0000000000000000000000000000000000000000..6214d02ffc1e15f7e2f318ddadf497d7b85b4976 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Cre_Mha_Prhd_3.java @@ -0,0 +1,161 @@ +//----------------------------------------------------------------------------- +//FWK_MHA_PRHD +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_prhd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +import uicc.access.UICCConstants; + + +public class Cre_Mha_Prhd_3 extends TestToolkitApplet { + + /** result of specific testcase */ + boolean bRes = false; + /** result of test in install method */ + static boolean bInstallRes = false; + /** number of testcase */ + private byte testCaseNb = (byte) 0x00; + /** */ + private boolean HANDLER_AVAILABLE = true; + /** list included registered all events */ +// private short eventList[] = { +// EVENT_EVENT_DOWNLOAD_NETWORK_SEARCH_MODE_CHANGE, +// EVENT_EVENT_BROWSING_STATUS, +// EVENT_PROACTIVE_HANDLER_AVAILABLE, +// }; + + + + /** */ + private Cre_Mha_Prhd_3 () {} + + + private byte[] baTestsResults = new byte[128]; + private byte[] baTestAppletId = new byte[17]; + + /** + * Create an instance of the Applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Cre_Mha_Prhd_3 applet = new Cre_Mha_Prhd_3(); + //initialize the data of the test applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + + applet.init(); + //register to the resto of the events +// applet.obReg.setEventList(applet.eventList,(short)0,(short)(applet.eventList.length)); + //register to file EF_TARU +// applet.obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE,new byte[]{(byte) 0x6F03},(short)0,(short)1,null,(short)0,(byte)0x00); + + // - TC 1.1 (ld 43) + // - The ProactiveResponseHandler is not available outside the processToolkit() method + try{ + bInstallRes=false; + //get the ProactiveResponseHandler + ProactiveResponseHandler proRHdr = ProactiveResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + bInstallRes=true; + } + } + } + + + public void process(APDU apdu) { + if (selectingApplet()){ + //- TC 1.2 (ld 43) + //- The ProactiveHandler is not available outside the processToolkit() method + if (testCaseNb==(byte)0x00){ + testCaseNb=(byte)0x01; + bRes=false; + try{ + ProactiveResponseHandler proRHdr = ProactiveResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE){ + //bRes can be only true if the first part of test (1.1) is not failed + if (bInstallRes==true){bRes=true;} + } + } + this.reportTestOutcome(testCaseNb,bRes); + } + + /* end of th test: result is sent to the Terminal */ + /* Construct and send the results of the tests */ + apdu.setOutgoing(); + apdu.setOutgoingLength((short)((short)(this.baTestAppletId[0] + this.baTestsResults[0]) + + (short)2)); + apdu.sendBytesLong(this.baTestAppletId, (short)0, (short)((short)(this.baTestAppletId[0]) + (short)1)); + apdu.sendBytesLong(this.baTestsResults, (short)0, (short)((short)(this.baTestsResults[0]) + (short)1)); + } + else{ + //call the implementation from the test applet + super.process(apdu); + } + } + + + /** + * Method called to initialize the AID + */ + public void init() throws SystemException { + + // Get the AID value + this.baTestAppletId[0] = JCSystem.getAID().getBytes(this.baTestAppletId, (short)1); + Util.arrayFillNonAtomic(this.baTestsResults, (short)0, (short)this.baTestsResults.length, (byte)0x00); + } + + /** + * Method called by the test applet to report the result of each test case + * + * @param testCaseNumber test case number + * @param result true if successful, false otherwise + */ + protected void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + this.baTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + this.baTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + this.baTestsResults[testCaseNumber] = (byte)0x00; + } + } + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + bRes=false; + + + + } + + +} + \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Test_Cre_Mha_Prhd.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Test_Cre_Mha_Prhd.java new file mode 100644 index 0000000000000000000000000000000000000000..29ae33a6585560771da02927a5a3f071ce5a7a73 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/Test_Cre_Mha_Prhd.java @@ -0,0 +1,336 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Sttg.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_mha_prhd; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Cre_Mha_Prhd extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/catre/cre_mha_prhd"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + /** test applet 1 class AID */ + private static String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + /** */ + private static String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000F"; + /** */ + private static String AID_ADF1 = "A0000000090005FFFFFFFF89E0000002"; + + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Cre_Mha_Prhd(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + + // test script + test.reset(); + test.terminalProfileSession("03010000 0102"); + + // Install Applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800C" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "01" + // V Max. number of timers + "20" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "03030404" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01" ); // V Maximum number of services + + test.reset(); + //TC 1 - select MF + response = test.selectFile("3F00"); + //TC 2 - send Terminal Profile except SET_EVENT_LIST,POLL_INTERVALL,SETUP_IDLE_MODE_TEXT,SET_UP_MENU + response = test.terminalProfileSession("FFFFDFD FFEFF1FEF FF0000FF FF9FFFEF" + + "03FF000 0007FE300 01"); + //TC 3 - initialization with all the facilities supported (without SETUP_EVENT_LIST + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + response = test.envelopeMenuSelection("900102","9500"); + testresult = response.checkSw("9000"); + //TC 4 + response = test.envelopeMenuSelection("900101",""); + testresult &= response.checkSw("9000"); + //TC 5 + response = test.envelopeTimerExpiration("A40101"); + //TC 6 + response = test.envelopeCallControlByNAA(); + testresult &= response.checkSw("9000"); + //TC 7 + response = test.envelopeEventDownloadMTCall(); + testresult &= response.checkSw("9000"); + //TC 8 + response = test.envelopeEventDownloadCallConnected(); + testresult &= response.checkSw("9000"); + //TC 9 + response = test.envelopeEventDownloadCallDisconnected(); + testresult &= response.checkSw("9000"); + //TC 10 + response = test.envelopeEventDownloadLocationStatus(); + testresult &= response.checkSw("9000"); + //TC 11 + response = test.envelopeEventDownloadUserActivity(); + testresult &= response.checkSw("9000"); + //TC 12 + response = test.envelopeEventDownloadIdleScreenAvailable(); + testresult &= response.checkSw("9000"); + //TC 13 + response = test.envelopeEventDownloadCardReaderStatus(); + testresult &= response.checkSw("9000"); + //TC 14 + response = test.envelopeEventDownloadLanguageSelection(); + testresult &= response.checkSw("9000"); + //TC 15 + response = test.envelopeEventDownloadBrowserTermination(); + testresult &= response.checkSw("9000"); + //TC 16 + response = test.status("00","0C","00"); + testresult &= response.checkSw("911A"); + //TC 17 + response = test.fetch("1A"); + response = test.terminalResponse("81030140 01820282 8183010038 0281003502 " + + "03003902 000A"); + testresult &= response.checkSw("9000"); + response = test.envelopeEventDownloadDataAvailable("B8028100"); + testresult &= response.checkSw("9000"); + //TC 18 + response = test.envelopeEventDownloadChannelStatus("B8028100"); + testresult &= response.checkSw("9000"); + //TC 19 + response = test.unrecognizedEnvelope(); + testresult &= response.checkSw("9000"); + //TC 20 + response = test.envelopeEventDownloadAccessTechnologyChange(); + testresult &= response.checkSw("9000"); + //TC 21 + response = test.envelopeEventDownloadDisplayParametersChanged(); + //fetch declare service + response = test.fetch("10"); + //get the service record tlv from declare service command + String servrectlv = getServiceRecordTLV(response.getData()); + response = test.terminalResponse("81030147 0082028281 830100"); + testresult &= response.checkSw("9000"); + //TC 22 + response = test.envelopeEventDownloadLocalConnection(servrectlv); + testresult &= response.checkSw("9000"); + //TC 23 + response = test.envelopeEventDownloadCallConnected(); + //fetch display text + response = test.fetch("14"); + response = test.terminalResponse("81030121 80820282 81030100"); + testresult &= response.checkSw("9000"); + //TC 24 + //- Select for activation ADF1 + response = test.selectApplication (AID_ADF1); + //- Select for termination ADF1 + response = test.sendApdu ("00A4044C 10"+AID_ADF1 ); + testresult &= response.checkSw("9000"); + //TC 25 + test.reset(); + //no terminal profile is sent and proactive handler shall not be available. + response = test.envelopeMenuSelection("900102","9500"); + //TC 26 + response = test.envelopeMenuSelection("900101",""); + //TC 27 + response = test.envelopeTimerExpiration("A40101"); + //TC 28 + response = test.envelopeCallControlByNAA(); + //TC 29 + response = test.envelopeEventDownloadMTCall(); + //TC 30 + response = test.envelopeEventDownloadCallConnected(); + //TC 31 + response = test.envelopeEventDownloadCallDisconnected(); + //TC 32 + response = test.envelopeEventDownloadLocationStatus(); + //TC 33 + response = test.envelopeEventDownloadUserActivity(); + //TC 34 + response = test.envelopeEventDownloadIdleScreenAvailable(); + //TC 35 + response = test.envelopeEventDownloadCardReaderStatus(); + //TC 36 + response = test.envelopeEventDownloadLanguageSelection(); + //TC 37 + response = test.envelopeEventDownloadBrowserTermination(); + //TC 38 + response = test.status("00","0C","00"); + //TC 39 + response = test.unrecognizedEnvelope(); + //TC 40 + response = test.envelopeEventDownloadAccessTechnologyChange(); + //TC 41 + response = test.envelopeEventDownloadDisplayParametersChanged(); + //TC 42 + //The Proactive Handler is not available before the + //Terminal Profile + //TC 43 + response = test.envelopeEventDownloadNetworkSearchModeChange(); + //TC 44 + response = test.envelopeEventDownloadBrowsingStatus(); + //TC 45 + test.reset(); + //initialization with all the facilities supported (without SETUP_EVENT_LIST) + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + response = test.envelopeEventDownloadNetworkSearchModeChange(); + testresult &= response.checkSw("9000"); + //TC 46 + response = test.envelopeEventDownloadBrowsingStatus(); + testresult &= response.checkSw("9000"); + //TC 47 + test.reset(); + // Install Applet + //initialization with all the facilities supported (without SETUP_EVENT_LIST) + response = test.terminalProfileSession("FFFFFFFF FEFFFFFF FFFFFFFF FFFFFFFF " + + "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF " + + "FFFF"); + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + response = test.selectApplication(APPLET_AID_3); + + + // get result from applets + test.reset(); + + // It is possible, based on implemenation of the card manufacturer, in + // case that a CAT facility is not supported by the terminal profile, + // the applet will not be triggered on an unsupported event. + response = test.selectApplication(APPLET_AID_1); + testresult &= (response.checkData("10" +APPLET_AID_1 + + "2DCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCC" + ) || + response.checkData("10" +APPLET_AID_1 + + "1CCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CC" + )); + + + response = test.selectApplication(APPLET_AID_2); + testresult &= response.checkData("10" +APPLET_AID_2 + + "22CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCC" + ) + || + response.checkData("10" +APPLET_AID_2 + + "15CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"+ + "CCCCCCCC CCCC" + ); + + + response = test.selectApplication(APPLET_AID_3); + testresult &= response.checkData("10" +APPLET_AID_3 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + + } + + + /** + * Converts a byte array to a hex string + * @param byteArray byte array[] + * @return the byte array as hex string:
+ * E.g: byteArray{(byte)0x11,(byte)0x22,(byte)0x33} will be returned + * as String "112233" + */ + private String byteArrayToHexString(byte[] byteArray){ + StringBuffer stringBuffer = new StringBuffer(); + for(int i=0; i22){ + temp=temp.substring(22);//cut off BER TLV, len command details and dev id + int len = Integer.valueOf(temp.substring(2,4),16).intValue(); + if (len==temp.length()){ + return temp; + } + else{ + // suppress UICC/terminal interface TLV + return temp.substring(0,(Integer.valueOf(temp.substring(2,4),16).intValue())*2+4); + } + } + else return ""; + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..08d2a6f9f2b9551e6aed50d58bc41e5b9fc63fc3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_mha_prhd.Cre_Mha_Prhd_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_mha_prhd.Cre_Mha_Prhd_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_mha_prhd.Cre_Mha_Prhd_1 +uicc.test.catre.cre_mha_prhd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/javacard/cre_mha_prhd.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/javacard/cre_mha_prhd.cap new file mode 100644 index 0000000000000000000000000000000000000000..79885c7eaae24cf6142529e21e25f28c418158e6 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_mha_prhd/javacard/cre_mha_prhd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/Cre_Pcs_Igco_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/Cre_Pcs_Igco_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6dbb1cb35c1969d0ca7e87a4c511bb1b8e82eca1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/Cre_Pcs_Igco_1.java @@ -0,0 +1,118 @@ +//----------------------------------------------------------------------------- +// Cre_Pce_Igco_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_igco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : sim.framework... + * + * Applet is triggered on Install (Install), EVENT_MENU_SELECTION + * + * @version 0.0.1 - 15/07/01 + * + */ + +public class Cre_Pcs_Igco_1 extends TestToolkitApplet +{ + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + + private static byte IDmenu01; + private static byte IDmenu02; + + byte[] Test = {(byte)'T',(byte)'e',(byte)'s',(byte)'t',(byte)' ',(byte)'A'} ; + + /** + * Constructor of the applet + */ + public Cre_Pcs_Igco_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Pcs_Igco_1 thisApplet = new Cre_Pcs_Igco_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + IDmenu01 = thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, + (short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + MenuInit [4] = (byte) '2'; + IDmenu02 = thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, + (short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + public void processToolkit(short event) + { + // Number of tests + byte testCaseNb = (byte)0; + // Result of tests + boolean bRes = false; + + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + if (event != EVENT_MENU_SELECTION) + return; + + // check menu ID + byte menuID = envHdlr.getItemIdentifier(); + + // ----------------------------------------------------------------- + // Test Case 2 : Menu Item 01 + // ----------------------------------------------------------------- + if( menuID == IDmenu01 ) + { + testCaseNb = (byte) 1; + Test[5] = (byte) 'A'; + proHdlr.initDisplayText((byte)0x00, (byte)0x04 /*DCS_8_BIT_DATA*/, Test, (short)0, (short)Test.length) ; + proHdlr.send() ; + + bRes = true; + } + + // ----------------------------------------------------------------- + // Test Case 3 : Menu Item 02 + // ----------------------------------------------------------------- + if( menuID == IDmenu02 ) + { + testCaseNb = (byte) 2; + Test[5] = (byte) 'B'; + proHdlr.initDisplayText((byte)0x00, (byte)0x04 /*DCS_8_BIT_DATA*/, Test, (short)0, (short)Test.length) ; + proHdlr.send() ; + + Test[5] = (byte) 'C'; + proHdlr.initDisplayText((byte)0x00, (byte)0x04 /*DCS_8_BIT_DATA*/, Test, (short)0, (short)Test.length) ; + proHdlr.send() ; + + bRes = true; + } + + reportTestOutcome(testCaseNb, bRes); + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/Test_Cre_Pcs_Igco.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/Test_Cre_Pcs_Igco.java new file mode 100644 index 0000000000000000000000000000000000000000..924867f4e766d2308e7ea009855e31db1e7c4db8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/Test_Cre_Pcs_Igco.java @@ -0,0 +1,197 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_igco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Pcs_Igco extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_pcs_igco"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Pcs_Igco() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // test script + test.reset(); + // Terminal Profile with Set Up Menu + response = test.terminalProfile("09010020"); + // SW1 shall be 91 + result = response.checkSw("9126"); + + // select MF + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9126"); + + // select failed + response = test.selectFile("03FF"); + // SW = 6A82 + result &= response.checkSw("6A82"); + + // Fetch the Set Up Menu + response = test.fetch("26"); + result &= response.checkData("D0248103 01250082 02818285 09554943" + + "43205445 53548F06 014D656E 75318F06" + + "024D656E 7532"); + + // select MF + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9000"); + + // Terminal Response + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + // SW1 shall be 91 + result = response.checkSw("9114"); + + // select MF + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9114"); + + // select failed + response = test.selectFile("03FF"); + // SW = 6A82 + result &= response.checkSw("6A82"); + + // Fetch display Text + response = test.fetch("14"); + result &= response.checkData("D0128103 01210082 0281028D 07045465" + + "73742041"); + + // select MF + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9000"); + + // Terminal Response + response = test.terminalResponse("81030121 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100102",""); + + // select MF (Testcase 3-1) + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9114"); + // Fetch display Text + response = test.fetch("14"); + result &= response.checkData("D0128103 01210082 0281028D 07045465" + + "73742042"); + + // select MF (Testcase 3-4) + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9000"); + // select failed + response = test.selectFile("03FF"); + // SW = 6A82 + result &= response.checkSw("6A82"); + // Terminal Response + response = test.terminalResponse("81030121 00820282 81830100"); + result &= response.checkSw("9114"); + + // select MF (Testcase 3-8) + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9114"); + // select failed + response = test.selectFile("03FF"); + // SW = 6A82 + result &= response.checkSw("6A82"); + // Fetch display Text + response = test.fetch("14"); + result &= response.checkData("D0128103 01210082 0281028D 07045465" + + "73742043"); + + // select MF (Testcase 3-12) + response = test.selectFile("3F00"); + result &= response.getData().regionMatches(16, "3F00", 0, 4); + result &= response.checkSw("9000"); + // Terminal Response + response = test.terminalResponse("81030121 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "02" + "CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5d879102bcf1ddc1db405ed74383e72acbaa5093 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_pcs_igco.Cre_Pcs_Igco_1 +uicc.test.catre.cre_pcs_igco +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/javacard/cre_pcs_igco.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/javacard/cre_pcs_igco.cap new file mode 100644 index 0000000000000000000000000000000000000000..d923b4f4904709d0600ca294b14df427a79925c6 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_igco/javacard/cre_pcs_igco.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ffce219fd135aefdf3787fa42e9dc3628c8428be --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_1.java @@ -0,0 +1,525 @@ +//----------------------------------------------------------------------------- +// Cre_Pcs_Pcco_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_pcco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : sim.tookit.EnvelopeHandler.getSecuredDataLength() + * + * Applet is triggered on Install (Install), EVENT_FORMATTED_SMS_PP_ENV + * + */ +public class Cre_Pcs_Pcco_1 extends TestToolkitApplet +{ + private static byte[] menuItem1 = {(byte) 0x01, (byte)'I', (byte)'t', (byte)'e', (byte)'m', (byte)' ', (byte)'1'}; + // Number of tests + byte testCaseNb = (byte) 0x00; + byte CaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Cre_Pcs_Pcco_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte length) + { + // Create a new applet instance + Cre_Pcs_Pcco_1 thisApplet = new Cre_Pcs_Pcco_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuItem1,(short)1,(short)(menuItem1.length - 1),(byte)0,false,(byte)0,(short)0); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes = false; + // Miscellaneous + byte bTimerNb = 0; + byte bServiceNb = 0; + final byte PRO_CMD_POLL_INTERVAL = (byte)0x03; + final byte PRO_CMD_POLLING_OFF = (byte)0x04; + final byte PRO_CMD_SET_UP_EVENT_LIST = (byte)0x05; + final byte PRO_CMD_SET_UP_MENU = (byte)0x25; + final byte[] menuTitle = {(byte)'M', (byte)'e', (byte)'n', (byte)'u'}; + final byte[] eventList = {(byte)0x01, (byte)0x02, (byte)0x03}; + final byte[] address = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + final byte[] CSDBearerDesc = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + final byte[] GPRSBearerDesc = {(byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x31}; + final byte[] timerValue = {(byte)0x00, (byte)0x01, (byte)0x00}; + final byte[] ServiceRecordValue = {(byte)0x00, (byte)0x00, (byte)0x00}; + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : TK Proactive Commands + // -------------------------------------------- + + //Sub Test Case 1 : SET UP MENU + // -------------------------------------------- + testCaseNb = (byte) 1 ; + CaseNb = (byte) 1 ; + bRes = false ; + + proHdlr.init(PRO_CMD_SET_UP_MENU, (byte)0x00, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ALPHA_IDENTIFIER, menuTitle, (short)0x00, (short)menuTitle.length); + proHdlr.appendTLV(TAG_ITEM_IDENTIFIER, menuItem1, (short)0x00, (short)menuItem1.length); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 2 : SET UP EVENT LIST + // -------------------------------------------- + CaseNb = (byte) 2 ; + bRes = false ; + + proHdlr.init(PRO_CMD_SET_UP_EVENT_LIST, (byte)0x00, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_EVENT_LIST, eventList, (short)0x00, (short)eventList.length); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 3 : POLL INTERVAL + // -------------------------------------------- + CaseNb = (byte) 3 ; + bRes = false ; + + proHdlr.init(PRO_CMD_POLL_INTERVAL, (byte)0x00, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_DURATION, (byte)0x01, (byte)0x02); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 4 : POLLING OFF + // -------------------------------------------- + CaseNb = (byte) 4 ; + bRes = false ; + + proHdlr.init(PRO_CMD_POLLING_OFF, (byte)0x00, (byte)DEV_ID_TERMINAL); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : TIMER MANAGEMENT proactive command + // -------------------------------------------- + testCaseNb = (byte) 2 ; + + // Applet 3 allocates 3 timers (Id 1 to 3) + // -------------------------------------------- + CaseNb = (byte) 5 ; + bRes = false ; + + try { + obReg.allocateTimer(); + obReg.allocateTimer(); + obReg.allocateTimer(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 2 : TIMER MANAGEMENT proactive command + // -------------------------------------------- + testCaseNb = (byte) 3 ; + + + // TIMER MANAGEMENT commands on allowed timers + // -------------------------------------------- + CaseNb = (byte) 6 ; + bRes = true ; + + for (bTimerNb = 1; bTimerNb < 4; bTimerNb++) + { + proHdlr.init(PRO_CMD_TIMER_MANAGEMENT, (byte)0x00, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_TIMER_IDENTIFIER, bTimerNb); + proHdlr.appendTLV(TAG_TIMER_VALUE, timerValue, (short)0x00, (short)timerValue.length); + try { + proHdlr.send(); + bRes &= true; + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(CaseNb, bRes) ; + + // TIMER MANAGEMENT commands on not allowed timers + // -------------------------------------------- + CaseNb = (byte) 7 ; + bRes = true ; + + for (bTimerNb = 4; bTimerNb < 9; bTimerNb++) + { + proHdlr.init(PRO_CMD_TIMER_MANAGEMENT, (byte)0x00, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_TIMER_IDENTIFIER, bTimerNb); + proHdlr.appendTLV(TAG_TIMER_VALUE, timerValue, (short)0x00, (short)timerValue.length); + try { + proHdlr.send(); + bRes &= false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes &= true ; + } + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 3 : No channel allowed + // -------------------------------------------- + testCaseNb = (byte) 4 ; + + //Sub Test Case 1 : CSD OPEN CHANNEL + // -------------------------------------------- + CaseNb = (byte) 8 ; + bRes = false ; + + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, address, (short)0x00, (short)address.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, CSDBearerDesc, (short)0x00, (short)CSDBearerDesc.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 2 : GPRS OPEN CHANNEL + // -------------------------------------------- + CaseNb = (byte) 9 ; + bRes = false ; + + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, GPRSBearerDesc, (short)0x00, (short)GPRSBearerDesc.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 3 : SEND DATA + // -------------------------------------------- + CaseNb = (byte) 10 ; + bRes = false ; + + proHdlr.init(PRO_CMD_SEND_DATA, (byte)0x01, (byte)0x21); + proHdlr.appendTLV(TAG_CHANNEL_DATA, (byte)0x55, (byte)0xAA); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 4 : RECEIVE DATA + // -------------------------------------------- + CaseNb = (byte) 11 ; + bRes = false ; + + proHdlr.init(PRO_CMD_RECEIVE_DATA, (byte)0x00, (byte)0x21); + proHdlr.appendTLV(TAG_CHANNEL_DATA_LENGTH, (byte)0x10); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + //Sub Test Case 5 : CLOSE CHANNEL + // -------------------------------------------- + CaseNb = (byte) 12 ; + bRes = false ; + + proHdlr.initCloseChannel((byte)0x01); + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : DECLARE SERVICE proactive command + // -------------------------------------------- + testCaseNb = (byte) 5 ; + + // Applet 3 allocates 3 services (Id 0 to 2) + // -------------------------------------------- + CaseNb = (byte) 13 ; + bRes = false ; + + try { + obReg.allocateServiceIdentifier(); + obReg.allocateServiceIdentifier(); + obReg.allocateServiceIdentifier(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 5 : DECLARE SERVICE proactive command + // -------------------------------------------- + testCaseNb = (byte) 6 ; + + + // DECLARE SERVICE "Add" commands on allowed services + // -------------------------------------------- + CaseNb = (byte) 14 ; + bRes = true ; + + for (bServiceNb = 0; bServiceNb < 3; bServiceNb++) + { + ServiceRecordValue[1] = bServiceNb; + proHdlr.init(PRO_CMD_DECLARE_SERVICE, (byte)0x00 /*Add*/, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_SERVICE_RECORD, ServiceRecordValue, (short)0x00, (short)ServiceRecordValue.length); + try { + proHdlr.send(); + bRes &= true; + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(CaseNb, bRes) ; + + // DECLARE SERVICE "Add" commands on not allowed servives + // -------------------------------------------- + CaseNb = (byte) 15 ; + bRes = true ; + + for (bServiceNb = 3; bServiceNb < 8; bServiceNb++) + { + ServiceRecordValue[1] = bServiceNb; + proHdlr.init(PRO_CMD_DECLARE_SERVICE, (byte)0x00 /*Add*/, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_SERVICE_RECORD, ServiceRecordValue, (short)0x00, (short)ServiceRecordValue.length); + try { + proHdlr.send(); + bRes &= false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes &= true ; + } + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(CaseNb, bRes) ; + + // DECLARE SERVICE "Delete" commands on allowed services + // -------------------------------------------- + CaseNb = (byte) 16 ; + bRes = true ; + + for (bServiceNb = 0; bServiceNb < 3; bServiceNb++) + { + ServiceRecordValue[1] = bServiceNb; + proHdlr.init(PRO_CMD_DECLARE_SERVICE, (byte)0x01 /*Delete*/, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_SERVICE_RECORD, ServiceRecordValue, (short)0x00, (short)ServiceRecordValue.length); + try { + proHdlr.send(); + bRes &= true; + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(CaseNb, bRes) ; + + // DECLARE SERVICE "Delete" commands on not allowed servives + // -------------------------------------------- + CaseNb = (byte) 17 ; + bRes = true ; + + for (bServiceNb = 3; bServiceNb < 8; bServiceNb++) + { + ServiceRecordValue[1] = bServiceNb; + proHdlr.init(PRO_CMD_DECLARE_SERVICE, (byte)0x01 /*Delete*/, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_SERVICE_RECORD, ServiceRecordValue, (short)0x00, (short)ServiceRecordValue.length); + try { + proHdlr.send(); + bRes &= false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes &= true ; + } + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 6 : Unknown proactive command + // -------------------------------------------- + testCaseNb = (byte) 7 ; + CaseNb = (byte) 18 ; + bRes = true; + proHdlr.init((byte)0x00, (byte)0x00, (byte)0x00); + proHdlr.appendTLV((byte)0x00,(byte)0x00, (byte)0x00); + try { + proHdlr.send(); + bRes &= true; + } + catch (Exception e) { + bRes &= false ; + } + reportTestOutcome(CaseNb, bRes) ; + + break; + + } // End switch + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_2.java new file mode 100644 index 0000000000000000000000000000000000000000..df2a96ca6f724ffa4b2485cc851dff95892248d3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_2.java @@ -0,0 +1,334 @@ +//----------------------------------------------------------------------------- +// Cre_Pcs_Pcco_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_pcco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : sim.tookit.EnvelopeHandler.getSecuredDataLength() + * + * Applet is triggered on Install (Install), EVENT_FORMATTED_SMS_PP_ENV + * + */ +public class Cre_Pcs_Pcco_2 extends TestToolkitApplet +{ + // Number of tests + byte testCaseNb = (byte) 0x00; + private static byte[] menuItem2 = {(byte)'I', (byte)'t', (byte)'e', (byte)'m', (byte)' ', (byte)'2', (byte)'2', (byte)'2', (byte)'2'}; + + /** + * Constructor of the applet + */ + public Cre_Pcs_Pcco_2 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Pcs_Pcco_2 thisApplet = new Cre_Pcs_Pcco_2 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuItem2,(short)0,(short)menuItem2.length,(byte)0,false,(byte)0,(short)0); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes; + // Miscellaneous + byte bTimerId; + byte bChannelNb; + byte bServiceId; + final byte[] address = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + final byte[] CSDBearerDesc = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + final byte[] GPRSBearerDesc = {(byte)0x02, (byte)0x01, (byte)0x01, (byte)0x02, (byte)0x01, (byte)0x31}; + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + switch ( testCaseNb ) + { + case (byte) 0 : + + // -------------------------------------------- + // Test Case 2 : TIMER MANAGEMENT proactive command + // -------------------------------------------- + testCaseNb = (byte) 1 ; + + try { + // Applet 2 allocates 8 timers + // -------------------------------------------- + for (bTimerId=0; bTimerId < 8; bTimerId++) + { + obReg.allocateTimer(); + } + // Applet 2 releases 3 timers (from id 1 to 3) + // -------------------------------------------- + for (bTimerId=1; bTimerId < 4; bTimerId++) + { + obReg.releaseTimer(bTimerId); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 1 : + + // -------------------------------------------- + // Test Case 2 : TIMER MANAGEMENT proactive command + // -------------------------------------------- + testCaseNb = (byte) 2 ; + + try { + // Applet 2 releases 4 timers (from id 4 to 7) + // -------------------------------------------- + for (bTimerId=4; bTimerId < 8; bTimerId++) + { + obReg.releaseTimer(bTimerId); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 4 : 4 channels allowed + // -------------------------------------------- + + // Build the CSD OPEN CHANNEL command to open channel 1 + // -------------------------------------------- + testCaseNb = (byte) 3 ; + bRes = false; + + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, address, (short)0x00, (short)address.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, CSDBearerDesc, (short)0x00, (short)CSDBearerDesc.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + try { + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Build the GPRS OPEN CHANNEL command to open channel 2 + // -------------------------------------------- + testCaseNb = (byte) 4 ; + bRes = false; + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, GPRSBearerDesc, (short)0x00, (short)GPRSBearerDesc.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + try { + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Build and send SEND DATA command on non allowed channels + // -------------------------------------------- + testCaseNb = (byte) 5 ; + bRes = true; + + for (bChannelNb = 0x23; bChannelNb <= 0x27 ; bChannelNb++) + { + proHdlr.init(PRO_CMD_SEND_DATA, (byte)0x01, bChannelNb); + proHdlr.appendTLV(TAG_CHANNEL_DATA, (byte)0x55, (byte)0xAA); + try { + proHdlr.send(); + bRes &= false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes &= true ; + } + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(testCaseNb, bRes) ; + + // Build and send RECEIVE DATA command on non allowed channels + // -------------------------------------------- + testCaseNb = (byte) 6 ; + bRes = true; + + for (bChannelNb = 0x23; bChannelNb <= 0x27 ; bChannelNb++) + { + proHdlr.init(PRO_CMD_RECEIVE_DATA, (byte)0x01, bChannelNb); + proHdlr.appendTLV(TAG_CHANNEL_DATA_LENGTH, (byte)0x10); + try { + proHdlr.send(); + bRes &= false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes &= true ; + } + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(testCaseNb, bRes) ; + + // Build and send CLOSE CHANNEL command on non allowed channels + // -------------------------------------------- + testCaseNb = (byte) 7 ; + bRes = true; + + for (bChannelNb = 0x03; bChannelNb <= 0x07 ; bChannelNb++) + { + proHdlr.initCloseChannel(bChannelNb); + try { + proHdlr.send(); + bRes &= false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes &= true ; + } + } + catch (Exception e) { + bRes &= false ; + } + } + reportTestOutcome(testCaseNb, bRes) ; + + // Build a CSD OPEN CHANNEL command to open channel 3 + // -------------------------------------------- + testCaseNb = (byte) 8 ; + bRes = false; + + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, address, (short)0x00, (short)address.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, CSDBearerDesc, (short)0x00, (short)CSDBearerDesc.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + try { + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Send a new CSD OPEN CHANNEL command + // -------------------------------------------- + testCaseNb = (byte) 9 ; + bRes = false; + + try { + proHdlr.send(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.COMMAND_NOT_ALLOWED) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 9 : + + // ----------------------------------------------- + // Test Case 5 : DECLARE SERVICE proactive command + // ----------------------------------------------- + testCaseNb = (byte) 10 ; + + try { + // Applet 2 allocates 8 services + // -------------------------------------------- + for (bServiceId=0; bServiceId < 8; bServiceId++) + { + obReg.allocateServiceIdentifier(); + } + // Applet 2 releases 3 services (from id 0 to 2) + // -------------------------------------------- + for (bServiceId=0; bServiceId < 3; bServiceId++) + { + obReg.releaseServiceIdentifier((byte)bServiceId); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 10 : + + // -------------------------------------------- + // Test Case 5 : DECLARE SERVICE proactive command + // -------------------------------------------- + testCaseNb = (byte) 11 ; + + try { + // Applet 2 releases 3 services (from id 5 to 7) + // -------------------------------------------- + for (bServiceId=4; bServiceId < 8; bServiceId++) + { + obReg.releaseServiceIdentifier(bServiceId); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + } // End switch + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_3.java new file mode 100644 index 0000000000000000000000000000000000000000..aba4baba141d1a9b6da222018b8480acd29318d7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Cre_Pcs_Pcco_3.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// Cre_Pcs_Pcco_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_pcco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : sim.tookit.EnvelopeHandler.getSecuredDataLength() + * + * Applet is triggered on Install (Install), EVENT_FORMATTED_SMS_PP_ENV + * + */ +public class Cre_Pcs_Pcco_3 extends TestToolkitApplet +{ + // Number of tests + byte testCaseNb = (byte) 0x00; + private static byte[] menuItem3 = {(byte)'I', (byte)'t', (byte)'e', (byte)'m', (byte)' ', (byte)'3'}; + + /** + * Constructor of the applet + */ + public Cre_Pcs_Pcco_3 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Pcs_Pcco_3 thisApplet = new Cre_Pcs_Pcco_3 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuItem3,(short)0,(short)menuItem3.length,(byte)0,false,(byte)0,(short)0); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes; + // Miscelaneous + final byte[] address = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + final byte[] CSDBearerDesc = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 4 : 4 channels allowed + // -------------------------------------------- + testCaseNb = (byte) 1 ; + bRes = false; + + // Build the CSD OPEN CHANNEL command to open channel 7 + // -------------------------------------------- + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, address, (short)0x00, (short)address.length); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, CSDBearerDesc, (short)0x00, (short)CSDBearerDesc.length); + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + try { + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Test_Cre_Pcs_Pcco.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Test_Cre_Pcs_Pcco.java new file mode 100644 index 0000000000000000000000000000000000000000..535f7c42081a91841dbc4a8d274c5c800154a946 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/Test_Cre_Pcs_Pcco.java @@ -0,0 +1,301 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_pcco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Pcs_Pcco extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_pcs_pcco"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Pcs_Pcco() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Load package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "04" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "04" ); // V Maximum number of services + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "03" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "08" ); // V Maximum number of services + // Install Applet3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("01016020 00000003 0000000F E3"); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + // SW = 9000 + result = response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102",""); + // SW = 9000 + result &= response.checkSw("9000"); + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + // SW = 9000 + result &= response.checkSw("9000"); + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102",""); + // SW = 9000 + result &= response.checkSw("9000"); + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + // SW = 9000 + result &= response.checkSw("9113"); + + // Fecth 3 Timer Management proactive commands + response = test.fetch("13"); + result &= response.checkData("D0118103 01270082 02818224 01012503" + + "000100"); + response = test.terminalResponse("81030127 00820282 81030100 24010125" + + "03000100"); + result &= response.checkSw("9113"); + response = test.fetch("13"); + result &= response.checkData("D0118103 01270082 02818224 01022503" + + "000100"); + response = test.terminalResponse("81030127 00820282 81030100 24010125" + + "03000100"); + result &= response.checkSw("9113"); + response = test.fetch("13"); + result &= response.checkData("D0118103 01270082 02818224 01032503" + + "000100"); + response = test.terminalResponse("81030127 00820282 81030100 24010125" + + "03000100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + // SW = 9000 + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Trigger Applet3 + response = test.envelopeMenuSelection("100103",""); + // SW = 911C + result &= response.checkSw("911C"); + // Fetch the Open Channel + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + // Terminal Response OK on channel 7 + response = test.terminalResponse("81030140 01820282 81030100 38028700" + + "35040100 00003902 0080"); + result &= response.checkSw("9000"); + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102",""); + // SW = 911C + result &= response.checkSw("911C"); + // Fetch the Open Channel CSD + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + // Terminal Response OK on channel 1 + response = test.terminalResponse("81030140 01820282 81030100 38028100" + + "35040100 00003902 0080"); + result &= response.checkSw("9117"); + // Fetch the Open Channel GPRS + response = test.fetch("17"); + result &= response.checkData("D0158103 01400182 02818235 06020101" + + "02013139 020080"); + // Terminal Response OK on channel 2 + response = test.terminalResponse("81030140 01820282 81030100 38028200" + + "35060201 01020131 39020080"); + result &= response.checkSw("911C"); + // Fetch the Open Channel CSD + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + // Terminal Response OK on channel 3 + response = test.terminalResponse("81030140 01820282 81030100 38028300" + + "35040100 00003902 0080"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102",""); + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + result &= response.checkSw("9000"); + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102",""); + result &= response.checkSw("9000"); + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + result &= response.checkSw("9110"); + + // Fecth 3 Declare Service "Add" proactive commands + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470082 02818241 03000000"); + response = test.terminalResponse("81030147 00820282 81030100"); + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470082 02818241 03000100"); + response = test.terminalResponse("81030147 00820282 81030100"); + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470082 02818241 03000200"); + response = test.terminalResponse("81030147 00820282 81030100"); + result &= response.checkSw("9110"); + + // Fecth 3 Declare Service "Delete" proactive commands + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470182 02818241 03000000"); + response = test.terminalResponse("81030147 01820282 81030100"); + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470182 02818241 03000100"); + response = test.terminalResponse("81030147 01820282 81030100"); + result &= response.checkSw("9110"); + response = test.fetch("10"); + result &= response.checkData("D00E8103 01470182 02818241 03000200"); + response = test.terminalResponse("81030147 01820282 81030100"); + result &= response.checkSw("9000"); + + + + /*********************************************************************/ + /** Testcase 6 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + result &= response.checkSw("910F"); + + // Fecth 3 unknown proactive commande + response = test.fetch("0F"); + result &= response.checkData("D00D8103 01000082 02810000 020000"); + response = test.terminalResponse("81030100 00820282 81030100"); + result &= response.checkSw("9000"); + + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "12" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "0B" + + "CCCCCCCC CCCCCCCC CCCCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01" + "CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..bfccd6187ba116a98ec2d0120dc4db9f05cd23a1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_pcs_pcco.Cre_Pcs_Pcco_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_pcs_pcco.Cre_Pcs_Pcco_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_pcs_pcco.Cre_Pcs_Pcco_1 +uicc.test.catre.cre_pcs_pcco +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/javacard/cre_pcs_pcco.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/javacard/cre_pcs_pcco.cap new file mode 100644 index 0000000000000000000000000000000000000000..e1d3028b9152b96947a82b7fb87c681bdcb8485c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_pcco/javacard/cre_pcs_pcco.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_1.java new file mode 100644 index 0000000000000000000000000000000000000000..215655defbc21bb613118f1920c5c9a21de88d21 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_1.java @@ -0,0 +1,188 @@ +//----------------------------------------------------------------------------- +// Cre_Pcs_Spco_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_spco; + +import javacard.framework.Util; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +public class Cre_Pcs_Spco_1 extends TestToolkitApplet +{ + + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private static byte[] Text1 = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'1'} ; + private static byte testCaseNb = (byte) 0x00; + private static boolean bRes = false; + private static byte nbMenuTriggering = (byte)0; + private static byte nbEnvTriggering = (byte)0; + private static boolean firstInstall = true; + private static byte[] baLocalTestsResults = new byte[128]; + + + /** + * Constructor of the applet + */ + public Cre_Pcs_Spco_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + // Create a new applet instance. + Cre_Pcs_Spco_1 thisApplet = new Cre_Pcs_Spco_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // ----------------------------------------------------------------- + // Test Case 1 : init MenuEntrys and Send SET UP MENU after Install + // ----------------------------------------------------------------- + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short)MenuInit.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.setEvent((short) EVENT_EVENT_DOWNLOAD_MT_CALL); + thisApplet.obReg.setEvent((short) EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + if (firstInstall) + { + firstInstall = false; + testCaseNb=(byte)0x01; + Util.arrayFillNonAtomic(baLocalTestsResults, (short)0, (short)baLocalTestsResults.length, (byte)0x00); + baLocalTestsResults[0] = (byte)testCaseNb; + baLocalTestsResults[1] = (byte)0xCC; + } + else + { + thisApplet.obReg.setEvent((short) EVENT_UNRECOGNIZED_ENVELOPE); + } + + } + + /** + * Method reportLocalTestOutcome() is used to save result throw applet deletion + * @param testCaseNumber + * @param testCaseResult + */ + protected void reportLocalTestOutcome(byte testCaseNumber, boolean testCaseResult) + { + // Update the total number of tests executed + baLocalTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + baLocalTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + baLocalTestsResults[testCaseNumber] = (byte)0x00; + } + + for (byte n = 1; n <= testCaseNumber; n++) + reportTestOutcome(n, (boolean)(baLocalTestsResults[n] == (byte)0xCC)); + } + + public void processToolkit(short event) + { + bRes = false; + + switch (event) + { + case EVENT_MENU_SELECTION: + nbMenuTriggering++; + switch (nbMenuTriggering) + { + case 1: + // ----------------------------------------------------------------- + // Test Case 4 : disable menu + // ----------------------------------------------------------------- + obReg.disableMenuEntry((byte)0x01); + testCaseNb = (byte)2; + bRes = true; + break; + case 2: + // ----------------------------------------------------------------- + // Test Case 8 : clear EVENT_EVENT_DOWNLOAD_MT_CALL + // ----------------------------------------------------------------- + obReg.clearEvent((short) EVENT_EVENT_DOWNLOAD_MT_CALL); + testCaseNb = (byte)3; + bRes = true; + break; + case 3: + // ----------------------------------------------------------------- + // Test Case 8 : set EVENT_EVENT_DOWNLOAD_MT_CALL + // ----------------------------------------------------------------- + obReg.setEvent((short) EVENT_EVENT_DOWNLOAD_MT_CALL); + testCaseNb = (byte)5; + bRes = true; + break; + } + break; + + case EVENT_EVENT_DOWNLOAD_MT_CALL: + obReg.enableMenuEntry((byte)0x01); + testCaseNb = (byte)4; + bRes = true; + break; + + case EVENT_EVENT_DOWNLOAD_LOCATION_STATUS: + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + testCaseNb = (byte)6; + bRes = true; + break; + + case EVENT_STATUS_COMMAND: + // ----------------------------------------------------------------- + // Test Case 12 : + // ----------------------------------------------------------------- + obReg.requestPollInterval(POLL_NO_DURATION); + testCaseNb = (byte)7; + bRes = true; + break; + + case EVENT_UNRECOGNIZED_ENVELOPE: + nbEnvTriggering++; + if (nbEnvTriggering == 1) + { + // ----------------------------------------------------------------- + // Test Case 12 : + // ----------------------------------------------------------------- + obReg.requestPollInterval(POLL_SYSTEM_DURATION); + testCaseNb = (byte)8; + bRes = true; + } + else + { + // ----------------------------------------------------------------- + // Test Case 13 : + // ----------------------------------------------------------------- + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + obReg.disableMenuEntry((byte)1); + obReg.requestPollInterval(POLL_NO_DURATION); + obReg.clearEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + proHdlr.initDisplayText((byte)0x00, (byte)0x04 /*DCS_8_BIT_DATA*/, Text1, (short)0, (short)Text1.length) ; + proHdlr.send() ; + testCaseNb = (byte)9; + bRes = true; + } + break; + + default: + testCaseNb = (byte)10; + bRes = false; + } + reportLocalTestOutcome(testCaseNb, bRes); + } + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_2.java new file mode 100644 index 0000000000000000000000000000000000000000..4efbc992e90f57c88bb368b18a370f6ce09453a8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_2.java @@ -0,0 +1,247 @@ +//----------------------------------------------------------------------------- +// Cre_Pcs_Spco_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_spco; + +import javacard.framework.*; +import uicc.access.* ; +import uicc.test.util.* ; +import uicc.toolkit.*; + +public class Cre_Pcs_Spco_2 extends TestToolkitApplet +{ + private static short FID_EF_SUME = 0x6F54; + private static byte[] Menu = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'2'}; + private static byte[] Text21 = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'2',(byte)'1'} ; + private static byte[] Text22 = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'2',(byte)'2'} ; + private static byte[] boldTextAttr = {(byte)0x00, (byte)0x00, (byte)0x13, (byte)0x90}; + private static byte[] normalTextAttr = {(byte)0x00, (byte)0x00, (byte)0x03, (byte)0x90}; + private byte result = (byte) 0; + private byte NbTriggering = 0; + boolean bRes = false; + private static FileView UiccFileView = null; + + /** + * Constructor of the applet + */ + public Cre_Pcs_Spco_2() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Pcs_Spco_2 thisApplet = new Cre_Pcs_Spco_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(Menu, (short) 0, (short)Menu.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.setEvent((short) EVENT_UNRECOGNIZED_ENVELOPE); + + // Get the the Uicc File View + UiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + } + + + public void processToolkit(short event) + { + NbTriggering++; + bRes = false; + + switch (NbTriggering) + { + case 1: + try { + // ----------------------------------------------------------------- + // Test Case 1 + // ----------------------------------------------------------------- + UiccFileView.select(UICCConstants.FID_DF_TELECOM); + UiccFileView.select(FID_EF_SUME); + byte[] ba_Data = {(byte)0x85,(byte)0x09,(byte)0x54,(byte)0x45, + (byte)0x53,(byte)0x54,(byte)0x20,(byte)0x55, + (byte)0x49,(byte)0x43,(byte)0x43,(byte)0xFF, + (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF, + (byte)0xFF}; + UiccFileView.updateBinary((short)0, ba_Data, (short)0x00, (short)ba_Data.length); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + break; + case 2: + try { + // ----------------------------------------------------------------- + // Test Case 2 + // ----------------------------------------------------------------- + UiccFileView.select(UICCConstants.FID_DF_TELECOM); + UiccFileView.select(FID_EF_SUME); + byte[] ba_Data = {(byte)0x85,(byte)0x09,(byte)0x54,(byte)0x45, + (byte)0x53,(byte)0x54,(byte)0x20,(byte)0x55, + (byte)0x49,(byte)0x43,(byte)0x43,(byte)0x50, + (byte)0x04,(byte)0x00,(byte)0x00,(byte)0x13, + (byte)0x90}; + UiccFileView.updateBinary((short)0, ba_Data, (short)0x00, (short)ba_Data.length); + bRes = true; + + // Release FileView static reference + UiccFileView = null; + } + catch (Exception e) { + bRes = false; + } + break; + case 3: + try { + // ----------------------------------------------------------------- + // Test Case 8 + // ----------------------------------------------------------------- + obReg.setEvent((short)EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + obReg.setEvent((short)EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION); + bRes = true; + } + catch(Exception e) { + bRes = false; + } + break; + case 4: + try { + // ----------------------------------------------------------------- + // Test Case 8 + // ----------------------------------------------------------------- + if (event != EVENT_EVENT_DOWNLOAD_LOCATION_STATUS) + { + bRes = false; + break; + } + obReg.clearEvent((short)EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + obReg.clearEvent((short)EVENT_EVENT_DOWNLOAD_LANGUAGE_SELECTION); + bRes = true; + } + catch(Exception e) { + bRes = false; + } + break; + case 6: + try { + // ----------------------------------------------------------------- + // Test Case 13 + // ----------------------------------------------------------------- + if (event != EVENT_UNRECOGNIZED_ENVELOPE) + { + bRes = false; + break; + } + obReg.setEvent(EVENT_PROACTIVE_HANDLER_AVAILABLE); + obReg.disableMenuEntry((byte)2); + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + proHdlr.initDisplayText((byte)0x00, (byte)0x04 /*DCS_8_BIT_DATA*/, Text21, (short)0, (short)Text21.length) ; + proHdlr.send() ; + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 7: + try { + // ----------------------------------------------------------------- + // Test Case 13 + // ----------------------------------------------------------------- + if (event != EVENT_PROACTIVE_HANDLER_AVAILABLE) + { + bRes = false; + break; + } + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + proHdlr.initDisplayText((byte)0x00, (byte)0x04 /*DCS_8_BIT_DATA*/, Text22, (short)0, (short)Text22.length) ; + proHdlr.send() ; + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 8: + try { + // ----------------------------------------------------------------- + // Test Case 14-2 + // ----------------------------------------------------------------- + obReg.enableMenuEntry((byte)2); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 9: + try { + // ----------------------------------------------------------------- + // Test Case 14-5 + // ----------------------------------------------------------------- + obReg.setMenuEntryTextAttribute((byte)2, boldTextAttr, (short)0, (short)4); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 10: + try { + // ----------------------------------------------------------------- + // Test Case 14-7 + // ----------------------------------------------------------------- + obReg.disableMenuEntry((byte)2); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 11: + try { + // ----------------------------------------------------------------- + // Test Case 14-11 + // ----------------------------------------------------------------- + obReg.enableMenuEntry((byte)2); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 12: + try { + // ----------------------------------------------------------------- + // Test Case 14-13 + // ----------------------------------------------------------------- + obReg.setMenuEntryTextAttribute((byte)2, normalTextAttr, (short)0, (short)4); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + default: + if (event == EVENT_UNRECOGNIZED_ENVELOPE) + { + bRes = true; + break; + } + } + + reportTestOutcome((byte)NbTriggering, bRes); + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_3.java new file mode 100644 index 0000000000000000000000000000000000000000..44aa8de8daad2a8a0d3903fa4665002e868ea35e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Cre_Pcs_Spco_3.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +// Cre_Pcs_Spco_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_spco; + +import uicc.test.util.* ; + +public class Cre_Pcs_Spco_3 extends TestToolkitApplet +{ + private static short FID_EF_SUME = 0x6F54; + private static byte[] Menu = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'3'}; + private byte result = (byte) 0; + private byte NbTriggering = 0; + boolean bRes = false; + + /** + * Constructor of the applet + */ + public Cre_Pcs_Spco_3() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Pcs_Spco_3 thisApplet = new Cre_Pcs_Spco_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(Menu, (short) 0, (short)Menu.length, (byte) 0, false, (byte) 0, (short) 0); + } + + + public void processToolkit(short event) + { + NbTriggering++; + bRes = false; + + switch (NbTriggering) + { + case 1: + try { + // ----------------------------------------------------------------- + // Test Case 14-9 + // ----------------------------------------------------------------- + byte[] italicTextAttr = {(byte)0x00, (byte)0x00, (byte)0x23, (byte)0x90}; + obReg.setMenuEntryTextAttribute((byte)3, italicTextAttr, (byte)0, (short)4); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + case 2: + try { + // ----------------------------------------------------------------- + // Test Case 14-9 + // ----------------------------------------------------------------- + byte[] normalcTextAttr = {(byte)0x00, (byte)0x00, (byte)0x03, (byte)0x90}; + obReg.setMenuEntryTextAttribute((byte)3, normalcTextAttr, (byte)0, (short)4); + bRes = true; + } + catch (Exception e){ + bRes = false; + } + break; + } + + reportTestOutcome((byte)NbTriggering, bRes); + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Test_Cre_Pcs_Spco.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Test_Cre_Pcs_Spco.java new file mode 100644 index 0000000000000000000000000000000000000000..7f8b395e4b7b86643cf311079034b282adc0c1af --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/Test_Cre_Pcs_Spco.java @@ -0,0 +1,739 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_pcs_spco; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import java.lang.*; + +public class Test_Cre_Pcs_Spco extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_pcs_spco"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + static final String DF_TELECOM = "7F10"; + static final String EF_SUME = "6F54"; + + private UiccAPITestCardService test; + APDUResponse response; + + + // Fetch a sepUpMenu command, check it according to the parameters + // and send the Terminal Response. + // Return true if the received command corresponds to the one rebuilt using + // the parameters + private boolean fetchSetUpMenu( + String alphaId, // AlphaId TLV Value + String alphaIdTextAtt, // AlphaId Text Attribute TLV Value + byte nbMenu, // Number of menus + String[] menuId, // Menu Id List table + String[] menu, // Text Menu List table (in readable text!) + String nextActionTLV, // Next Action List TLV + String itemTextAttListTLV) // Item Text Attribute List TLV + { + boolean result; + String setUpMenuCmd = ""; + String endOfCmd = ""; + String Cmd = ""; + + // Build the Set Up Menu + if (nextActionTLV != null) + { + endOfCmd = nextActionTLV; + } + if (alphaIdTextAtt != null) + { + endOfCmd += "50" + ToString((byte)(alphaIdTextAtt.length()/2)) + alphaIdTextAtt; + } + if (itemTextAttListTLV != null) + { + endOfCmd += itemTextAttListTLV; + } + + String menuItem = ""; + String menuList = ""; + for (byte i = 0; i < nbMenu; i++) + { + menuItem = menuId[i]; + menuItem += ByteToString(menu[i].getBytes()); + menuList += "8F" + ToString((byte)(menuItem.length()/2)) + menuItem; + } + Cmd = menuList + endOfCmd; + + String alpId = ByteToString(alphaId.getBytes()); + setUpMenuCmd = "85" + ToString((byte)(alpId.length()/2)) + alpId; + setUpMenuCmd += Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "810301250082028182" + Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "D0" + ToString((byte)(Cmd.length()/2)) + Cmd; + + response = test.fetch(ToString((byte)(setUpMenuCmd.length()/2))); + result = response.checkData(setUpMenuCmd); + + test.terminalResponse("81030125 00820282 81830100"); + + return result; + } + + private String ByteToString( byte tab[] ) + { + byte[] tab2; + byte c; + int i, j, k; + + j = tab.length; + tab2 = new byte[ j*2]; + + k = 0; + for ( i=0; i>4)&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + + c = (byte)(tab[ i ]&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + } + + return new String( tab2 ); + } + + // byte => String + private String ToString( byte myByte ) + { + byte[] tab; + byte c; + int i, j, k; + + tab = new byte[1]; + tab[0] = myByte; + + return ByteToString( tab ); + } + + public Test_Cre_Pcs_Spco() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfile("09010020 00000000 00000000 00000008" + + "00000000 00000000 0000003F 7F"); + + // Fetch the SetUpMenu with main menu "UICC TEST" and no text attribute + String[] menuList = new String[6]; + String[] menuIdList = new String[6]; + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + String DefaultAttr = "00000390"; + String BoldAttr = "00001390"; + String ItalicAttr = "00002390"; + result = fetchSetUpMenu("UICC TEST", null, (byte)1, menuIdList, menuList, null, null); + + // Update EFsume with the new menu title "TEST MENU" in bold + test.selectFile(DF_TELECOM); + response = test.selectFile(EF_SUME); + result &= response.checkSw("9000"); + test.sendApdu("00D60000 11850954 45535420 4D454E55" + + "50040000 1390"); + + // Fetch The SetUpMenu with main menu "TEST MENU" and text attribute "00001390" (bold) + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + result &= fetchSetUpMenu("TEST MENU", BoldAttr, (byte)1, menuIdList, menuList, null, null); + + // Send an unrecognized envelope + test.unrecognizedEnvelope(); + // Fetch the SetUpMenu with main menu "TEST UICC" and no text attribute + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + result &= fetchSetUpMenu("TEST UICC", null, (byte)1, menuIdList, menuList, null, null); + + // Send an unrecognized envelope + test.unrecognizedEnvelope(); + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + result &= fetchSetUpMenu("TEST UICC", BoldAttr, (byte)1, menuIdList, menuList, null, null); + + + // restaure EFsume with the menu title "UICC TEST" and no attribute + test.selectFile(DF_TELECOM); + response = test.selectFile(EF_SUME); + result &= response.checkSw("9000"); + test.sendApdu("00D60000 11850955 49434320 54455354" + + "FFFFFFFF FFFF"); + + // Fetch the SetUpMenu with main menu "UICC TEST" and no text attribute + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)1, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + // Fetch the SetUpMenu with the menus + menuList[0] = "Menu1"; + menuIdList[0] = "01"; + menuList[1] = "Menu2"; + menuIdList[1] = "02"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)2, menuIdList, menuList, null, null); + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Lock Applet1 + test.lockApplication(APPLET_AID_1); + // Fetch the SetUpMenu with the menus + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)1, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Make selectable Applet1 + test.unlockApplication(APPLET_AID_1); + // Fetch the SetUpMenu with the menus + menuList[0] = "Menu1"; + menuIdList[0] = "01"; + menuList[1] = "Menu2"; + menuIdList[1] = "02"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)2, menuIdList, menuList, null, null); + + // Send an envelope menu selection - Applet1 disables its menu + test.envelopeMenuSelection("100101", ""); + // Fetch the SetUpMenu with the menus + menuList[0] = "Menu2"; + menuIdList[0] = "02"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)1, menuIdList, menuList, null, null); + + // Send an envelope event download MT Call - Applet1 enables its menu + test.envelopeEventDownloadMTCall(); + // Fetch the SetUpMenu with the menus + menuList[0] = "Menu1"; + menuIdList[0] = "01"; + menuList[1] = "Menu2"; + menuIdList[1] = "02"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)2, menuIdList, menuList, null, null); + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Terminal Profile with Set Up Event List and EventDownload facilities + test.reset(); + test.terminalProfile("09010000 FFFF"); + + // Fetch SetUpEventList command + response = test.fetch("0F"); + result &= response.checkData("D00D8103 01050082 02818219 020003") || + response.checkData("D00D8103 01050082 02818299 020003"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 6 */ + /*********************************************************************/ + + // Lock Applet1 + test.lockApplication(APPLET_AID_1); + // Fetch SetUpEventList command + response = test.fetch("0D"); + result &= response.checkData("D00B8103 01050082 02818219 00") || + response.checkData("D00B8103 01050082 02818299 00"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 7 */ + /*********************************************************************/ + + // Make selectable Applet1 + test.unlockApplication(APPLET_AID_1); + // Fetch SetUpEventList command + response = test.fetch("0F"); + result &= response.checkData("D00D8103 01050082 02818219 020003") || + response.checkData("D00D8103 01050082 02818299 020003"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 8 */ + /*********************************************************************/ + + // Trigger Applet1 + test.envelopeMenuSelection("100101", ""); + // Fetch SetUpEventList command + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01050082 02818219 0103") || + response.checkData("D00C8103 01050082 02818299 0103"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + // Trigger Applet2 + test.unrecognizedEnvelope(); + // Fetch SetUpEventList command + response = test.fetch("0F"); + result &= response.checkData("D00D8103 01050082 02818219 020307") || + response.checkData("D00D8103 01050082 02818299 020307"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + // Trigger Applets + test.envelopeEventDownloadLocationStatus(); + // Fetch SetUpEventList command + response = test.fetch("0D"); + result &= response.checkData("D00B8103 01050082 02818219 00") || + response.checkData("D00B8103 01050082 02818299 00"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + // Trigger Applet1 + test.envelopeMenuSelection("100101", ""); + // Fetch SetUpEventList command + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01050082 02818219 0100") || + response.checkData("D00C8103 01050082 02818299 0100"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + // Delete Applet1 + test.deleteApplet(APPLET_AID_1); + // Fetch SetUpEventList command + response = test.fetch("0D"); + result &= response.checkData("D00B8103 01050082 02818219 00") || + response.checkData("D00B8103 01050082 02818299 00"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + // Fetch SetUpEventList command + response = test.fetch("0F"); + result &= response.checkData("D00D8103 01050082 02818219 020003") || + response.checkData("D00D8103 01050082 02818299 020003"); + response = test.terminalResponse("81030105 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 9 */ + /*********************************************************************/ + + // Terminal Profile with polling facilities + test.reset(); + test.terminalProfile("290160"); + // Fetch Poll Interval command + response = test.fetch("0F"); + String pollInterCmd = response.getData(); + result &= pollInterCmd.regionMatches(0, "D00D8103010300820281820402", + 0, "D00D8103010300820281820402".length()) || + pollInterCmd.regionMatches(0, "D00D8103010300820281828402", + 0, "D00D8103010300820281828402".length()); + response = test.terminalResponse("81030103 00820282 81830100 84020010"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + + // Lock Applet1 + test.lockApplication(APPLET_AID_1); + // Fetch Polling Off command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01040082 028182"); + response = test.terminalResponse("81030104 00820282 81830100"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 11 */ + /*********************************************************************/ + + // Make selectable Applet1 + test.unlockApplication(APPLET_AID_1); + // Fetch Poll Interval command + response = test.fetch("0F"); + result &= response.checkData(pollInterCmd); + response = test.terminalResponse("81030103 00820282 81830100 84020010"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 12 */ + /*********************************************************************/ + + // Trigger Applet1 + test.status("00", "00", "16"); + // Fetch Polling Off command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01040082 028182"); + response = test.terminalResponse("81030104 00820282 81830100"); + result &= response.checkSw("9000"); + + // Trigger Applet1 + test.unrecognizedEnvelope(); + // Fetch Poll Interval command + response = test.fetch("0F"); + result &= response.checkData(pollInterCmd); + response = test.terminalResponse("81030103 00820282 81830100 84020010"); + result &= response.checkSw("9000"); + + // Delete Applet1 + test.deleteApplet(APPLET_AID_1); + // Fetch Polling Off command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01040082 028182"); + response = test.terminalResponse("81030104 00820282 81830100"); + result &= response.checkSw("9000"); + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + // Fetch Poll Interval command + response = test.fetch("0F"); + result &= response.checkData(pollInterCmd); + response = test.terminalResponse("81030103 00820282 81830100 84020010"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession("29016120 FFFF"); + + // Trigger Applet1 + test.unrecognizedEnvelope(); + // Fetch Diplay text + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06045465" + + "787431"); + response = test.terminalResponse("81030121 00820282 81830100"); + result &= response.checkSw("9114"); + + // Fetch Diplay text + response = test.fetch("14"); + result &= response.checkData("D0128103 01210082 0281028D 07045465" + + "78743231"); + response = test.terminalResponse("81030121 00820282 81830100"); + result &= response.checkSw("9114"); + + // Fetch Diplay text + response = test.fetch("14"); + result &= response.checkData("D0128103 01210082 0281028D 07045465" + + "78743232"); + response = test.terminalResponse("81030121 00820282 81830100"); + + for (byte i = 0; i < 3; i++) + { + switch (Integer.valueOf(response.getStatusWord(),16).intValue()) + { + case 0x9118: + // Fetch an empty SetUpMenu + response = test.fetch("18"); + result &= response.checkData("D0168103 01250082 02818285 09554943" + + "43205445 53548F00"); + response = test.terminalResponse("81030125 00820282 81830100"); + break; + case 0x910E: + response = test.fetch("0E"); + result &= response.checkData("D00C8103 01050082 02818219 0103") || + response.checkData("D00C8103 01050082 02818299 0103"); + response = test.terminalResponse("81030105 00820282 81830100"); + break; + case 0x910B: + // Fetch Polling Off command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01040082 028182"); + response = test.terminalResponse("81030104 00820282 81830100"); + break; + default: + result = false; + break; + } + } + + /*********************************************************************/ + /** Testcase 14 */ + /*********************************************************************/ + + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // test script + test.reset(); + // Terminal Profile with Set Up Menu + response = test.terminalProfile("09010020 00000000 00000000 00000008" + + "00000000 00000000 0000003F 7F"); + // Fetch the SetUpMenu + response = test.fetch(response.getStatusWord().substring(2)); + result &= response.checkData("D01C8103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 7533") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 75335104" + + "00000390") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 7533D104" + + "00000390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet2 (testcase 14-2) + response = test.unrecognizedEnvelope(); + // Fetch the SetUpMenu + response = test.fetch(response.getStatusWord().substring(2)); + result &= response.checkData("D0248103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 7533") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 75335108 00000390 00000390") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "024D656E 7533D108 00000390 00000390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet2 (testcase 14-4) + test.envelopeMenuSelection("100102", ""); + // Fetch the SetUpMenu + response = test.fetch("30"); + result &= response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 75335108 00001390 00000390") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 7533D108 00001390 00000390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet2 (testcase 14-6) + response = test.envelopeMenuSelection("100102", ""); + // Fetch the SetUpMenu + response = test.fetch(response.getStatusWord().substring(2)); + result &= response.checkData("D01C8103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 7533") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 75335104" + + "00000390") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 7533D104" + + "00000390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet3 (testcase 14-8) + test.envelopeMenuSelection("100103", ""); + // Fetch the SetUpMenu + response = test.fetch("24"); + result &= response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 75335104" + + "00002390") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 034D656E 7533D104" + + "00002390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet2 (testcase 14-10) + test.unrecognizedEnvelope(); + // Fetch the SetUpMenu + response = test.fetch("30"); + result &= response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 75335108 00001390 00002390") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 7533D108 00001390 00002390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet2 (testcase 14-12) + test.envelopeMenuSelection("100102", ""); + // Fetch the SetUpMenu + response = test.fetch("30"); + result &= response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 75335108 00000390 00002390") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 7533D108 00000390 00002390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Lock Applet3 (testcase 14-14) + response = test.lockApplication(APPLET_AID_3); + // Fetch the SetUpMenu + response = test.fetch(response.getStatusWord().substring(2)); + result &= response.checkData("D01C8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 7532") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75325104" + + "00000390") || + response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 7532D104" + + "00000390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Make selectable Applet3 (testcase 14-15) + test.unlockApplication(APPLET_AID_3); + // Fetch the SetUpMenu + response = test.fetch("30"); + result &= response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 75335108 00000390 00002390") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 7533D108 00000390 00002390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + //Trigger Applet3 (testcase 14-16) + response = test.envelopeMenuSelection("100103", ""); + // Fetch the SetUpMenu + response = test.fetch(response.getStatusWord().substring(2)); + result &= response.checkData("D0248103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 7533") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "034D656E 75335108 00000390 00000390") || + response.checkData("D02E8103 01250082 02818285 09554943" + + "43205445 53548F06 024D656E 75328F06" + + "024D656E 7533D108 00000390 00000390"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "09" + + "CCCCCCCC CCCCCCCC CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "0C" + + "CCCCCCCC CCCCCCCC CCCCCCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "02" + + "CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..586b76ec81e6d80042b3696f5a44fab7215d4aad --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_pcs_spco.Cre_Pcs_Spco_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_pcs_spco.Cre_Pcs_Spco_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_pcs_spco.Cre_Pcs_Spco_1 +uicc.test.catre.cre_pcs_spco +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/javacard/cre_pcs_spco.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/javacard/cre_pcs_spco.cap new file mode 100644 index 0000000000000000000000000000000000000000..f062d768837bb7a1fe85ad39fc0c480117002f9f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_pcs_spco/javacard/cre_pcs_spco.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Cre_Reg_Evtr_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Cre_Reg_Evtr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..0bb09a89a8f7d99f67590169bb0fb38fbf193d86 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Cre_Reg_Evtr_1.java @@ -0,0 +1,65 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_reg_evtr; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * Cat Runtime Environment, Registration, Event Registration + * Applet1 + */ + +public class Cre_Reg_Evtr_1 extends TestToolkitApplet { + + private byte testCaseNb; + private boolean bRes; + + // Constructor of the applet + public Cre_Reg_Evtr_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // create a new applet instance + Cre_Reg_Evtr_1 thisApplet = new Cre_Reg_Evtr_1(); + + // register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // initialise the data of the test applet + thisApplet.init(); + + // registration to EVENT_EVENT_DOWNLOAD_USER_ACTIVITY and EVENT_EVENT_DOWNLOAD_MT_CALL + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + testCaseNb = 0x01; + try { + obReg.setEvent(EVENT_EVENT_DOWNLOAD_LOCATION_STATUS); + obReg.clearEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Cre_Reg_Evtr_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Cre_Reg_Evtr_2.java new file mode 100644 index 0000000000000000000000000000000000000000..6f17e52460d82ae665c67a0876cc3365abe5ae79 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Cre_Reg_Evtr_2.java @@ -0,0 +1,73 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_reg_evtr; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * Cat Runtime Environment, Registration, Event Registration + * Applet2 + */ + +public class Cre_Reg_Evtr_2 extends TestToolkitApplet { + + private byte testCaseNb; + private boolean bRes; + + byte[] readData = new byte[10]; + + private static byte testCounter = 0; + + // Constructor of the applet + public Cre_Reg_Evtr_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // create a new applet instance + Cre_Reg_Evtr_2 thisApplet = new Cre_Reg_Evtr_2(); + + // register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // initialise the data of the test applet + thisApplet.init(); + + // register to UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public Shareable getShareableInterfaceObject(AID clientAID, byte parameter) { + testCounter++; + // According to CAT Runtime Environment behaviour for ToolkitInterface object retrieval + if ((clientAID == null) && (parameter == (byte)0x01)) { + return((Shareable) this); + } else { + return(null); + } + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + testCaseNb = 0x01; + bRes = false; + if (testCounter == (byte)0x01) { + bRes = true; + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Test_Cre_Reg_Evtr.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Test_Cre_Reg_Evtr.java new file mode 100644 index 0000000000000000000000000000000000000000..817d0453f80abd36c7fc7c909306c35faad2149f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/Test_Cre_Reg_Evtr.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_reg_evtr; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + + +public class Test_Cre_Reg_Evtr extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_reg_evtr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Reg_Evtr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101000033"); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installInstallApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.status("00", "0C", "00"); + + // test script + response = test.makeSelectableApplet(APPLET_AID_1); + result = response.checkSw("910F"); + response = test.fetch("0F"); + result &= (response.checkData("D00D8103 01050082 02818299 020004") || + response.checkData("D00D8103 01050082 02818219 020004")); + test.terminalResponse("81030105 00820282 81830100"); + + // test case 1: trigger applet1 + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("910F"); + response = test.fetch("0F"); + result &= response.checkData("D00D8103 01050082 02818299 020003"); + test.terminalResponse("81030105 00820282 81830100"); + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("0101000033"); + + + // test case 2: trigger applet2 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01CC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01CC"); + + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3091ddee33e75da79cd6a474941b75ae6a917b60 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_reg_evtr.Cre_Reg_Evtr_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_reg_evtr.Cre_Reg_Evtr_1 +uicc.test.catre.cre_reg_evtr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/javacard/cre_reg_evtr.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/javacard/cre_reg_evtr.cap new file mode 100644 index 0000000000000000000000000000000000000000..9963b3d9d33d85afa87e897fd032303d99b0f9b5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_reg_evtr/javacard/cre_reg_evtr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_1.java new file mode 100644 index 0000000000000000000000000000000000000000..56d92e3837cd5e3fb2503ddece6cc24d5669fa46 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_1.java @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_1 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'2'}; + final boolean bSecurityException = false; + final boolean bSuccessExecution = true; + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + byte bTestCaseNb = 0; + byte[] abTestResults = null; + UICCTestConstants testConstants = null; + Cre_Tin_Acdo_8 commonTests = null; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_1() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + commonTests = new Cre_Tin_Acdo_8(); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_1 thisApplet = new Cre_Tin_Acdo_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = true; + boolean bIsAdminFVTest = false; + + // ----------------------------------------------------------------- + // Test Case 1 : Full access Applet + // ----------------------------------------------------------------- + + if (event == EVENT_MENU_SELECTION) { + byte bMenuId = 0; + + try + { + bMenuId = (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier()); + } + catch (Exception e) + { + // Debug purpose: only testcase 0x01 Ok if handler not available + reportTestOutcome((byte)0x01, true); + return; + } + + // Fileview access tests + try + { + if (bMenuId == 1) + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + ADF1View = UICCSystem.getTheFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = false; + } + else if (bMenuId == 2) + { + // Get admin fileviews... + UICCView = (FileView)AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + ADF1View = (FileView)AdminFileViewBuilder.getTheAdminFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = true; + + // Reset local testCaseNumber + commonTests.resetCaseNumber(); + } + + commonTests.SetFileViewRef(UICCView, ADF1View); + } + catch(Exception e) + { + // Debug purpose: only testcase 2 (menuID1) or 3 (menuId2) OK, if fileview not available + reportTestOutcome((byte)(bMenuId + 1), true); + return; + } + + // Sub cases 1.1 & 2.1 : Access tests on cyclic EF methods access + // ------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb == 2) + // Security exception is expected on EFCARR2 + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.2 & 2.2 : Access tests on linear fixed EF methods access + // -------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb == 2) + // Security exception is expected on EFLARR2 + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.3 & 2.3 : Access tests on transparent EF methods access + // ------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb == 2) + // Security exception is expected on EFTARR2 + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 2.4 to 2.6 : Access tests administrative commands + // ----------------------------------------------------------- + if (bMenuId == 2) + { + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb == 2) + // Security exception is expected on EFTAR2T + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSecurityException); + else + // No exception expected + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSuccessExecution); + } + } + + // Update Outcome report with result table + // --------------------------------------- + for (byte n = 1; n <= abTestResults[0]; n++) + { + reportTestOutcome(n, (abTestResults[n] == (byte)0xCC)); + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_2.java new file mode 100644 index 0000000000000000000000000000000000000000..24f99f0521b6a2c56c5b196ccedc587b3fef9886 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_2.java @@ -0,0 +1,160 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_2 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'2'}; + final boolean bSecurityException = false; + final boolean bSuccessExecution = true; + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + byte bTestCaseNb = 0; + byte[] abTestResults = null; + UICCTestConstants testConstants = null; + Cre_Tin_Acdo_8 commonTests = null; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_2() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + commonTests = new Cre_Tin_Acdo_8(); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_2 thisApplet = new Cre_Tin_Acdo_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = true; + boolean bIsAdminFVTest = false; + + // ----------------------------------------------------------------- + // Test Case 2 : No access Applet + // ----------------------------------------------------------------- + + if (event == EVENT_MENU_SELECTION) { + byte bMenuId = 0; + + try + { + bMenuId = (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier()); + } + catch (Exception e) + { + // Debug purpose: only testcase 0x01 Ok if handler not available + reportTestOutcome((byte)0x01, true); + return; + } + + // Fileview access tests + try + { + if (bMenuId == 1) + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + ADF1View = UICCSystem.getTheFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = false; + } + else if (bMenuId == 2) + { + // Get admin fileviews... + UICCView = (FileView)AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + ADF1View = (FileView)AdminFileViewBuilder.getTheAdminFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = true; + + // Reset local testCaseNumber + commonTests.resetCaseNumber(); + } + + commonTests.SetFileViewRef(UICCView, ADF1View); + } + catch(Exception e) + { + // Debug purpose: only testcase 2 (menuID1) or 3 (menuId2) OK, if fileview not available + reportTestOutcome((byte)(bMenuId + 1), true); + return; + } + + // Sub cases 1.1 & 2.1 : Access tests on cyclic EF methods access + // ------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + // Security exception is expected + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + } + + // Sub cases 1.2 & 2.2 : Access tests on linear fixed EF methods access + // -------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + // Security exception is expected + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + } + + // Sub cases 1.3 & 2.3 : Access tests on transparent EF methods access + // ------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + // Security exception is expected + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + } + + // Sub cases 2.4 to 2.6 : Access tests administrative commands + // ----------------------------------------------------------- + if (bMenuId == 2) + { + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + // Security exception is expected + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSecurityException); + } + } + + // Update Outcome report with result table + // --------------------------------------- + for (byte n = 1; n <= abTestResults[0]; n++) + { + reportTestOutcome(n, (abTestResults[n] == (byte)0xCC)); + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_3.java new file mode 100644 index 0000000000000000000000000000000000000000..67eab05dbfa9d2db59d51a70b5d438b3ee3da37a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_3.java @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_3 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'2'}; + final boolean bSecurityException = false; + final boolean bSuccessExecution = true; + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + byte bTestCaseNb = 0; + byte[] abTestResults = null; + UICCTestConstants testConstants = null; + Cre_Tin_Acdo_8 commonTests = null; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_3() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + commonTests = new Cre_Tin_Acdo_8(); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_3 thisApplet = new Cre_Tin_Acdo_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = true; + boolean bIsAdminFVTest = false; + + // ----------------------------------------------------------------- + // Test Case 3 : Always access right Applet + // ----------------------------------------------------------------- + + if (event == EVENT_MENU_SELECTION) { + byte bMenuId = 0; + + try + { + bMenuId = (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier()); + } + catch (Exception e) + { + // Debug purpose: only testcase 0x01 Ok if handler not available + reportTestOutcome((byte)0x01, true); + return; + } + + // Fileview access tests + try + { + if (bMenuId == 1) + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + ADF1View = UICCSystem.getTheFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = false; + } + else if (bMenuId == 2) + { + // Get admin fileviews... + UICCView = (FileView)AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + ADF1View = (FileView)AdminFileViewBuilder.getTheAdminFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = true; + + // Reset local testCaseNumber + commonTests.resetCaseNumber(); + } + + commonTests.SetFileViewRef(UICCView, ADF1View); + } + catch(Exception e) + { + // Debug purpose: only testcase 2 (menuID1) or 3 (menuId2) OK, if fileview not available + reportTestOutcome((byte)(bMenuId + 1), true); + return; + } + + // Sub cases 1.1 & 2.1 : Access tests on cyclic EF methods access + // ------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 1) + // Security exception is expected, except on EFCARR1 + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.2 & 2.2 : Access tests on linear fixed EF methods access + // -------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 1) + // Security exception is expected, except on EFLARR1 + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.3 & 2.3 : Access tests on transparent EF methods access + // ------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 1) + // Security exception is expected, except on EFTARR1 + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 2.4 to 2.6 : Access tests administrative commands + // ----------------------------------------------------------- + if (bMenuId == 2) + { + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 1) + // Security exception is expected, except on EFTAR1T + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSecurityException); + else + // No exception expected + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSuccessExecution); + } + } + + // Update Outcome report with result table + // --------------------------------------- + for (byte n = 1; n <= abTestResults[0]; n++) + { + reportTestOutcome(n, (abTestResults[n] == (byte)0xCC)); + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_4.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_4.java new file mode 100644 index 0000000000000000000000000000000000000000..69992c60dd29bdfbb1d4eb5172df994433869330 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_4.java @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_4.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_4 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'2'}; + final boolean bSecurityException = false; + final boolean bSuccessExecution = true; + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + byte bTestCaseNb = 0; + byte[] abTestResults = null; + UICCTestConstants testConstants = null; + Cre_Tin_Acdo_8 commonTests = null; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_4() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + commonTests = new Cre_Tin_Acdo_8(); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_4 thisApplet = new Cre_Tin_Acdo_4(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = true; + boolean bIsAdminFVTest = false; + + // ----------------------------------------------------------------- + // Test Case 4 : Global PIN2 access right Applet + // ----------------------------------------------------------------- + + if (event == EVENT_MENU_SELECTION) { + byte bMenuId = 0; + + try + { + bMenuId = (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier()); + } + catch (Exception e) + { + // Debug purpose: only testcase 0x01 Ok if handler not available + reportTestOutcome((byte)0x01, true); + return; + } + + // Fileview access tests + try + { + if (bMenuId == 1) + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + ADF1View = UICCSystem.getTheFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = false; + } + else if (bMenuId == 2) + { + // Get admin fileviews... + UICCView = (FileView)AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + ADF1View = (FileView)AdminFileViewBuilder.getTheAdminFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = true; + + // Reset local testCaseNumber + commonTests.resetCaseNumber(); + } + + commonTests.SetFileViewRef(UICCView, ADF1View); + } + catch(Exception e) + { + // Debug purpose: only testcase 2 (menuID1) or 3 (menuId2) OK, if fileview not available + reportTestOutcome((byte)(bMenuId + 1), true); + return; + } + + // Sub cases 1.1 & 2.1 : Access tests on cyclic EF methods access + // ------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 4) + // Security exception is expected, except on EFCARR4 + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.2 & 2.2 : Access tests on linear fixed EF methods access + // -------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 4) + // Security exception is expected, except on EFLARR4 + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.3 & 2.3 : Access tests on transparent EF methods access + // ------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 4) + // Security exception is expected, except on EFTARR4 + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 2.4 to 2.6 : Access tests administrative commands + // ----------------------------------------------------------- + if (bMenuId == 2) + { + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 4) + // Security exception is expected, except on EFTAR4T + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSecurityException); + else + // No exception expected + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSuccessExecution); + } + } + + // Update Outcome report with result table + // --------------------------------------- + for (byte n = 1; n <= abTestResults[0]; n++) + { + reportTestOutcome(n, (abTestResults[n] == (byte)0xCC)); + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_5.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_5.java new file mode 100644 index 0000000000000000000000000000000000000000..acfbd5a1e0fff868ce2d9f209dc049fde7d9287b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_5.java @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_5.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_5 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'2'}; + final boolean bSecurityException = false; + final boolean bSuccessExecution = true; + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + byte bTestCaseNb = 0; + byte[] abTestResults = null; + UICCTestConstants testConstants = null; + Cre_Tin_Acdo_8 commonTests = null; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_5() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + commonTests = new Cre_Tin_Acdo_8(); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_5 thisApplet = new Cre_Tin_Acdo_5(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = true; + boolean bIsAdminFVTest = false; + + // ----------------------------------------------------------------- + // Test Case 5 : Global PIN1 & ADM1 access right Applet + // ----------------------------------------------------------------- + + if (event == EVENT_MENU_SELECTION) { + byte bMenuId = 0; + + try + { + bMenuId = (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier()); + } + catch (Exception e) + { + // Debug purpose: only testcase 0x01 Ok if handler not available + reportTestOutcome((byte)0x01, true); + return; + } + + // Fileview access tests + try + { + if (bMenuId == 1) + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + ADF1View = UICCSystem.getTheFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = false; + } + else if (bMenuId == 2) + { + // Get admin fileviews... + UICCView = (FileView)AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + ADF1View = (FileView)AdminFileViewBuilder.getTheAdminFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = true; + + // Reset local testCaseNumber + commonTests.resetCaseNumber(); + } + + commonTests.SetFileViewRef(UICCView, ADF1View); + } + catch(Exception e) + { + // Debug purpose: only testcase 2 (menuID1) or 3 (menuId2) OK, if fileview not available + reportTestOutcome((byte)(bMenuId + 1), true); + return; + } + + // Sub cases 1.1 & 2.1 : Access tests on cyclic EF methods access + // ------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if ((bARRNb != 3) && (bARRNb != 4)) + // Security exception is expected, except on EFCARR3 and EFCARR4 + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.2 & 2.2 : Access tests on linear fixed EF methods access + // -------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if ((bARRNb != 3) && (bARRNb != 4)) + // Security exception is expected, except on EFLARR3 and EFLARR4 + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.3 & 2.3 : Access tests on transparent EF methods access + // ------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if ((bARRNb != 3) && (bARRNb != 4)) + // Security exception is expected, except on EFTARR3 and EFTARR4 + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 2.4 to 2.6 : Access tests administrative commands + // ----------------------------------------------------------- + if (bMenuId == 2) + { + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if ((bARRNb != 3) && (bARRNb != 4)) + // Security exception is expected, except on EFTAR3T and EFTAR4T + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSecurityException); + else + // No exception expected + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSuccessExecution); + } + } + + // Update Outcome report with result table + // --------------------------------------- + for (byte n = 1; n <= abTestResults[0]; n++) + { + reportTestOutcome(n, (abTestResults[n] == (byte)0xCC)); + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_6.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_6.java new file mode 100644 index 0000000000000000000000000000000000000000..3736781c493ce7f2978f386f45e9b36d3cd475bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_6.java @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_6.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_6 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1',(byte)'2'}; + final boolean bSecurityException = false; + final boolean bSuccessExecution = true; + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + byte bTestCaseNb = 0; + byte[] abTestResults = null; + UICCTestConstants testConstants = null; + Cre_Tin_Acdo_8 commonTests = null; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_6() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + commonTests = new Cre_Tin_Acdo_8(); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_6 thisApplet = new Cre_Tin_Acdo_6(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = true; + boolean bIsAdminFVTest = false; + + // ----------------------------------------------------------------- + // Test Case 3 : Local PIN & ADM2 access right Applet + // ----------------------------------------------------------------- + + if (event == EVENT_MENU_SELECTION) { + byte bMenuId = 0; + + try + { + bMenuId = (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier()); + } + catch (Exception e) + { + // Debug purpose: only testcase 0x01 Ok if handler not available + reportTestOutcome((byte)0x01, true); + return; + } + + // Fileview access tests + try + { + if (bMenuId == 1) + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + ADF1View = UICCSystem.getTheFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = false; + } + else if (bMenuId == 2) + { + // Get admin fileviews... + UICCView = (FileView)AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + ADF1View = (FileView)AdminFileViewBuilder.getTheAdminFileView(AID1, JCSystem.CLEAR_ON_RESET); + bIsAdminFVTest = true; + + // Reset local testCaseNumber + commonTests.resetCaseNumber(); + } + + commonTests.SetFileViewRef(UICCView, ADF1View); + } + catch(Exception e) + { + // Debug purpose: only testcase 2 (menuID1) or 3 (menuId2) OK, if fileview not available + reportTestOutcome((byte)(bMenuId + 1), true); + return; + } + + // Sub cases 1.1 & 2.1 : Access tests on cyclic EF methods access + // ------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 5) + // Security exception is expected, except on EFCARR5 + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.cyclicEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.2 & 2.2 : Access tests on linear fixed EF methods access + // -------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 5) + // Security exception is expected, except on EFLARR5 + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.linearEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 1.3 & 2.3 : Access tests on transparent EF methods access + // ------------------------------------------------------------------- + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 5) + // Security exception is expected, except on EFTARR5 + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSecurityException); + else + // No exception expected + abTestResults = commonTests.transpEFTests(bARRNb, bIsAdminFVTest, bSuccessExecution); + } + + // Sub cases 2.4 to 2.6 : Access tests administrative commands + // ----------------------------------------------------------- + if (bMenuId == 2) + { + for (byte bARRNb = 1; bARRNb < 6; bARRNb++) + { + if (bARRNb != 5) + // Security exception is expected, except on EFTAR5T + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSecurityException); + else + // No exception expected + abTestResults = commonTests.adminCmdAccessTests(bARRNb, bSuccessExecution); + } + } + + // Update Outcome report with result table + // --------------------------------------- + for (byte n = 1; n <= abTestResults[0]; n++) + { + reportTestOutcome(n, (abTestResults[n] == (byte)0xCC)); + } + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_7.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_7.java new file mode 100644 index 0000000000000000000000000000000000000000..70062c6f170639f0e86e5758b80fdae336857fbf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_7.java @@ -0,0 +1,316 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_6.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.* ; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_7 extends TestToolkitApplet +{ + private static byte[] MenuInit1 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + private static byte[] MenuInit2 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'2'}; + private static byte[] MenuInit3 = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'3'}; + AID AID1 = null; + FileView UICCView = null; + AdminFileView UICCAdminView = null; + byte bTestCaseNb = 0; + byte[] abRdBin = null; + UICCTestConstants testConstants = null; + + + /** + * Constructor of the applet + */ + + public Cre_Tin_Acdo_7() + { + testConstants = new UICCTestConstants(); + AID1 = new AID(testConstants.AID_ADF1, (short)0, (byte)testConstants.AID_ADF1.length); + abRdBin = new byte[3]; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance. + Cre_Tin_Acdo_7 thisApplet = new Cre_Tin_Acdo_7(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(MenuInit1, (short) 0, (short)MenuInit1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit2, (short) 0, (short)MenuInit2.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(MenuInit3, (short) 0, (short)MenuInit3.length, (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) + { + boolean bRes = false; + byte bMenuId = 0; + + // ----------------------------------------------------------------- + // Test Case 7 : AdminFileview and Fileview acces domain parameter differenciation + // ----------------------------------------------------------------- + + bMenuId = (byte)EnvelopeHandlerSystem.getTheHandler().getItemIdentifier(); + + switch(bMenuId) + { + case 1: + // Fileview access tests + try + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + } + catch(Exception e) + { + return; + } + + // Sub cases 1.1 : successful FileView access + // ------------------------------------------ + UICCView.select(UICCTestConstants.FID_DF_TEST); + UICCView.select(UICCTestConstants.FID_EF_TARR1); + try + { + UICCView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 1, bRes); + + // Sub cases 1.2 : Unsuccessful FileView access + // -------------------------------------------- + UICCView.select(UICCTestConstants.FID_DF_TEST); + UICCView.select(UICCTestConstants.FID_EF_TARR5); + try + { + UICCView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = false; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 2, bRes); + + // Sub cases 1.3 : Successful FileView access + // ------------------------------------------ + UICCView.select(UICCTestConstants.FID_DF_TEST); + UICCView.select(UICCTestConstants.FID_EF_TARR4); + try + { + UICCView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 3, bRes); + + break; + + case 2: + // Fileview access tests + try + { + // Get fileviews... + UICCAdminView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + } + catch(Exception e) + { + return; + } + + // Sub cases 4.1 : Unsuccessful adminFileView access + // ------------------------------------------------- + UICCAdminView.select(UICCTestConstants.FID_DF_TEST); + UICCAdminView.select(UICCTestConstants.FID_EF_TARR1); + try + { + UICCAdminView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = false; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 1, bRes); + + // Sub cases 4.2 : successful adminFileView access + // ----------------------------------------------- + UICCAdminView.select(UICCTestConstants.FID_DF_TEST); + UICCAdminView.select(UICCTestConstants.FID_EF_TARR5); + try + { + UICCAdminView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 2, bRes); + + + // Sub cases 4.3 : Successful adminFileView access + // ----------------------------------------------- + UICCAdminView.select(UICCTestConstants.FID_DF_TEST); + UICCAdminView.select(UICCTestConstants.FID_EF_TARR4); + try + { + UICCAdminView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 3, bRes); + break; + + case 3: + // Fileview access tests + try + { + // Get fileviews... + UICCView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + UICCAdminView = AdminFileViewBuilder.getTheUICCAdminFileView(JCSystem.CLEAR_ON_RESET); + } + catch(Exception e) + { + return; + } + + // Sub cases 7.1 : successful FileView access + // ------------------------------------------ + UICCView.select(UICCTestConstants.FID_DF_TEST); + UICCView.select(UICCTestConstants.FID_EF_TARR1); + try + { + UICCView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 1, bRes); + + // Sub cases 7.2 : Unsuccessful adminFileView access + // ------------------------------------------------- + UICCAdminView.select(UICCTestConstants.FID_DF_TEST); + UICCAdminView.select(UICCTestConstants.FID_EF_TARR1); + try + { + UICCAdminView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = false; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 2, bRes); + + // Sub cases 7.3 : successful adminFileView access + // ----------------------------------------------- + UICCAdminView.select(UICCTestConstants.FID_DF_TEST); + UICCAdminView.select(UICCTestConstants.FID_EF_TARR5); + try + { + UICCAdminView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 3, bRes); + + // Sub cases 7.2 : Unsuccessful FileView access + // -------------------------------------------- + UICCView.select(UICCTestConstants.FID_DF_TEST); + UICCView.select(UICCTestConstants.FID_EF_TARR5); + try + { + UICCView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = false; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 4, bRes); + + // Sub cases 7.5 : Successful FileView access + // ------------------------------------------ + UICCView.select(UICCTestConstants.FID_DF_TEST); + UICCView.select(UICCTestConstants.FID_EF_TARR4); + try + { + UICCView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 5, bRes); + + // Sub cases 7.6 : Successful adminFileView access + // ----------------------------------------------- + UICCAdminView.select(UICCTestConstants.FID_DF_TEST); + UICCAdminView.select(UICCTestConstants.FID_EF_TARR4); + try + { + UICCAdminView.readBinary((short)0, abRdBin, (short)0, (short)abRdBin.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte) 6, bRes); + break; + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_8.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_8.java new file mode 100644 index 0000000000000000000000000000000000000000..2ad739ad0ec8bfaeb75f7d2f8f18f74bcab6f556 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Cre_Tin_Acdo_8.java @@ -0,0 +1,751 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Acdo_8.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.access.*; +import uicc.system.*; +import uicc.access.fileadministration.*; +import uicc.test.util.* ; + + +public class Cre_Tin_Acdo_8 +{ + private byte[] abUpRec = {0x22, 0x22, 0x22}; + private byte[] abUpbin = {0x11, 0x11, 0x11}; + private byte[] abInc = {0x00, 0x00, 0x00}; + private byte[] abRdRec = null; + private byte[] abRes = null; + private short[] asSearch = null; + private byte bTestCaseNb = (byte) 0x00; + private short[] asCyclicEF = {(short)0, UICCTestConstants.FID_EF_CARR1, UICCTestConstants.FID_EF_CARR2, UICCTestConstants.FID_EF_CARR3, UICCTestConstants.FID_EF_CARR4, UICCTestConstants.FID_EF_CARR5}; + private short[] asLinearEF = {(short)0, UICCTestConstants.FID_EF_LARR1, UICCTestConstants.FID_EF_LARR2, UICCTestConstants.FID_EF_LARR3, UICCTestConstants.FID_EF_LARR4, UICCTestConstants.FID_EF_LARR5}; + private short[] asTranspEF = {(short)0, UICCTestConstants.FID_EF_TARR1, UICCTestConstants.FID_EF_TARR2, UICCTestConstants.FID_EF_TARR3, UICCTestConstants.FID_EF_TARR4, UICCTestConstants.FID_EF_TARR5}; + private short[] asAccessDF = {(short)0, UICCTestConstants.FID_DF_ARR1, UICCTestConstants.FID_DF_ARR2, UICCTestConstants.FID_DF_ARR3, UICCTestConstants.FID_DF_ARR4, UICCTestConstants.FID_DF_ARR5}; + private short[] asAccessEF = {(short)0, UICCTestConstants.FID_EF_TAR1T, UICCTestConstants.FID_EF_TAR2T, UICCTestConstants.FID_EF_TAR3T, UICCTestConstants.FID_EF_TAR4T, UICCTestConstants.FID_EF_TAR5T}; + private byte [] abCreateEF = { + (byte)0x82,(byte)0x02, // Tag, Length - File descriptor + (byte)0x41,(byte)0x21, // Value - File descriptor (Transparent) + (byte)0x83,(byte)0x02, // Tag, Length - File Id + (byte)0xEF,(byte)0x00, // Value - File Id + (byte)0x8A,(byte)0x01,(byte)0x05, // Tag, Length, Value - LCSI (Activated) + (byte)0x8B,(byte)0x03, // Tag, Length - Security attribute + (byte)0x2F,(byte)0x06,(byte)0x01, // Value - Security attribute (EF Arr, record nb) + (byte)0x80,(byte)0x01,(byte)0x05, // Tag, Length, value - File size (5 bytes) + (byte)0x88,(byte)0x00}; // Tag, Length - SFI (no SFI) + private byte [] abCreateEF_inADF = { + (byte)0x82,(byte)0x02, // Tag, Length - File descriptor + (byte)0x41,(byte)0x21, // Value - File descriptor (Transparent) + (byte)0x83,(byte)0x02, // Tag, Length - File Id + (byte)0xEF,(byte)0x00, // Value - File Id + (byte)0x8A,(byte)0x01,(byte)0x05, // Tag, Length, Value - LCSI (Activated) + (byte)0x8B,(byte)0x03, // Tag, Length - Security attribute + (byte)0x6F,(byte)0x06,(byte)0x01, // Value - Security attribute (EF Arr, record nb) + (byte)0x80,(byte)0x01,(byte)0x05, // Tag, Length, value - File size (5 bytes) + (byte)0x88,(byte)0x00}; // Tag, Length - SFI (no SFI) + private byte [] abResizeEF = { + (byte)0x83,(byte)0x02, // Tag, Length - File Id + (byte)0xEF,(byte)0x00, // Value - File Id + (byte)0x80,(byte)0x01,(byte)0x0A}; // Tag, Length, value - File size (5 bytes) + AID AID1 = null; + FileView UICCView = null; + FileView ADF1View = null; + ViewHandler createEFCmd = null; + ViewHandler resizeCmd = null; + byte abTestsResults[] = null; + + public Cre_Tin_Acdo_8() + { + abTestsResults = new byte[128]; + Util.arrayFillNonAtomic(abTestsResults, (short)0, (short)abTestsResults.length, (byte)0x00); + abRdRec = new byte[3]; + abRes = new byte[6]; + asSearch = new short[3]; + bTestCaseNb = 0; + } + + public void SetFileViewRef(FileView theUICCView, FileView theADF1View) + { + UICCView = theUICCView; + ADF1View = theADF1View; + } + + public void resetCaseNumber() + { + bTestCaseNb = 0; + } + + private void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + abTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + abTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + abTestsResults[testCaseNumber] = (byte)0x00; + } + } + + public byte[] cyclicEFTests(byte bARRNb, boolean bIsAdminFVTest, boolean bIsSuccess) + { + boolean bRes = false; + try + { + // Common calls to FileView and AdminFileView + UICCView.select((short) UICCTestConstants.FID_DF_TEST); + ADF1View.select((short) UICCTestConstants.FID_DF_TEST); + UICCView.select((short) asCyclicEF[bARRNb]); + ADF1View.select((short) asCyclicEF[bARRNb]); + + // Deactivate Command + // ------------------ + try + { + UICCView.deactivateFile(); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.deactivateFile(); + bRes &= true;//bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 1-7-13-19-25- + + // Activate Command + // ---------------- + try + { + UICCView.activateFile(); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.activateFile(); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 2-8-14-20-26 - + + // Update Record Command + // --------------------- + try + { + UICCView.updateRecord((short)0, UICCConstants.REC_ACC_MODE_PREVIOUS, (short)0, + abUpRec, (short)0, (short)abUpRec.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.updateRecord((short)0, UICCConstants.REC_ACC_MODE_PREVIOUS, (short)0, + abUpRec, (short)0, (short)abUpRec.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 3-9-15-21-27 - + + // Read Record Command + // ------------------- + try + { + UICCView.readRecord((short)0, UICCConstants.REC_ACC_MODE_CURRENT, (short)0, + abRdRec, (short)0, (short)abRdRec.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.readRecord((short)0, UICCConstants.REC_ACC_MODE_CURRENT, (short)0, + abRdRec, (short)0, (short)abRdRec.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 4-10-16-22-28 - + + // Search Record Command + // --------------------- + try + { + UICCView.searchRecord(UICCConstants.SIMPLE_SEARCH_START_FORWARD, (short) 0, (short)0, + abRdRec, (short)0, (short)abRdRec.length, + asSearch, (short)0, (short)asSearch.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.searchRecord(UICCConstants.SIMPLE_SEARCH_START_FORWARD, (short) 0, (short)0, + abRdRec, (short)0, (short)abRdRec.length, + asSearch, (short)0, (short)asSearch.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 5-11-17-23-29 - + + // Increase Command + // ---------------- + try + { + UICCView.increase(abInc, (short)0, (short)abInc.length, abRes, (short)0); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.increase(abInc, (short)0, (short)abInc.length, abRes, (short)0); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 6-12-18-24-30 - + } + catch (Exception e) + { + return abTestsResults; + } + return abTestsResults; + } + + public byte[] linearEFTests(byte bARRNb, boolean bIsAdminFVTest, boolean bIsSuccess) + { + boolean bRes = false; + try + { + // Common calls to FileView and AdminFileView + UICCView.select((short) UICCTestConstants.FID_DF_TEST); + ADF1View.select((short) UICCTestConstants.FID_DF_TEST); + UICCView.select((short) asLinearEF[bARRNb]); + ADF1View.select((short) asLinearEF[bARRNb]); + + // Deactivate Command + // ------------------ + try + { + UICCView.deactivateFile(); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.deactivateFile(); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 31-36-41-46-51 - + + // Activate Command + // ---------------- + try + { + UICCView.activateFile(); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.activateFile(); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 32-37-42-47-52 - + + // Update Record Command + // --------------------- + try + { + UICCView.updateRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + abUpRec, (short)0, (short)abUpRec.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.updateRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + abUpRec, (short)0, (short)abUpRec.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 33-38-43-48-53 - + + // Read Record Command + // ------------------- + try + { + UICCView.readRecord((short)0, UICCConstants.REC_ACC_MODE_CURRENT, (short)0, + abRdRec, (short)0, (short)abRdRec.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.readRecord((short)0, UICCConstants.REC_ACC_MODE_CURRENT, (short)0, + abRdRec, (short)0, (short)abRdRec.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 34-39-44-49-54 - + + // Search Record Command + // --------------------- + try + { + UICCView.searchRecord(UICCConstants.SIMPLE_SEARCH_START_FORWARD, (short) 0, (short)0, + abRdRec, (short)0, (short)abRdRec.length, + asSearch, (short)0, (short)asSearch.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.searchRecord(UICCConstants.SIMPLE_SEARCH_START_FORWARD, (short) 0, (short)0, + abRdRec, (short)0, (short)abRdRec.length, + asSearch, (short)0, (short)asSearch.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 35-40-45-50-55 - + } + catch (Exception e) + { + return abTestsResults; + } + return abTestsResults; + } + + public byte[] transpEFTests(byte bARRNb, boolean bIsAdminFVTest, boolean bIsSuccess) + { + boolean bRes = false; + try + { + // Common calls to FileView and AdminFileView + UICCView.select((short) UICCTestConstants.FID_DF_TEST); + ADF1View.select((short) UICCTestConstants.FID_DF_TEST); + UICCView.select((short) asTranspEF[bARRNb]); + ADF1View.select((short) asTranspEF[bARRNb]); + + // Deactivate Command + // ------------------ + try + { + UICCView.deactivateFile(); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.deactivateFile(); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 56-60-64-68-72 - + + // Activate Command + // ---------------- + try + { + UICCView.activateFile(); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.activateFile(); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 57-61-65-69-73 - + + // Update Binary Command + // --------------------- + try + { + UICCView.updateBinary((short)0, abUpbin, (short)0, (short)abUpbin.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.updateBinary((short)0, abUpbin, (short)0, (short)abUpbin.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 58-62-66-70-74 - + + // Read Binary Command + // ------------------- + try + { + UICCView.readBinary((short)0, abRdRec, (short)0, (short)abRdRec.length); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + ADF1View.readBinary((short)0, abRdRec, (short)0, (short)abRdRec.length); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 59-63-67-71-75 - + } + catch (Exception e) + { + return abTestsResults; + } + return abTestsResults; + } + + public byte[] adminCmdAccessTests(byte bARRNb, boolean bIsSuccess) + { + boolean bRes = false; + try + { + AdminFileView adminUICCView = (AdminFileView) UICCView; + AdminFileView adminADF1View = (AdminFileView) ADF1View; + + // AdminFileView methods call only + adminUICCView.select(UICCTestConstants.FID_MF); + adminADF1View.select(UICCTestConstants.FID_ADF); + adminUICCView.select(UICCTestConstants.FID_DF_TEST); + adminADF1View.select(UICCTestConstants.FID_DF_TEST); + adminUICCView.select(asAccessDF[bARRNb]); + adminADF1View.select(asAccessDF[bARRNb]); + + // Create Command + // -------------- + //Create EF with access rule bARRNb in EF 0xAC00 + abCreateEF[15] = (byte)bARRNb; + createEFCmd = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, (short)abCreateEF.length, abCreateEF, (short)0x00, (short)abCreateEF.length); + try + { + adminUICCView.createFile(createEFCmd); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + abCreateEF_inADF[15] = (byte)bARRNb; + createEFCmd = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, (short)abCreateEF_inADF.length, abCreateEF_inADF, (short)0x00, (short)abCreateEF_inADF.length); + try + { + adminADF1View.createFile(createEFCmd); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 76-79-82-85-88 + + // Resize Command + // -------------- + if (bIsSuccess) // file 0xEF00 not created + { + abResizeEF[2] = (byte)0xEF; + abResizeEF[3] = (byte)0x00; + } + else + { + abResizeEF[2] = (byte)((asAccessEF[bARRNb] >> 8) & 0x00FF); + abResizeEF[3] = (byte)(asAccessEF[bARRNb] & 0x00FF); + } + resizeCmd = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, (short)abResizeEF.length, abResizeEF, (short)0x00, (short)abResizeEF.length); + try + { + adminUICCView.resizeFile(resizeCmd); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + adminADF1View.resizeFile(resizeCmd); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 77-80-83-86-89 + + // Delete Command + // -------------- + try + { + if (bIsSuccess) + adminUICCView.deleteFile((short)0xEF00); + else + adminUICCView.deleteFile(asAccessEF[bARRNb]); + bRes = bIsSuccess; + } + catch (UICCException e) + { + bRes = (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + try + { + if (bIsSuccess) + adminADF1View.deleteFile((short)0xEF00); + else + adminADF1View.deleteFile(asAccessEF[bARRNb]); + bRes &= bIsSuccess; + } + catch (UICCException e) + { + bRes &= (e.getReason() == UICCException.SECURITY_STATUS_NOT_SATISFIED) && !bIsSuccess; + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome((byte)++bTestCaseNb, bRes); // testcaseNb = 78-81-84-87-90 + } + catch (Exception e) + { + return abTestsResults; + } + return abTestsResults; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Test_Cre_Tin_Acdo.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Test_Cre_Tin_Acdo.java new file mode 100644 index 0000000000000000000000000000000000000000..f4bb13407a4f096029349fc98c955affd269017e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/Test_Cre_Tin_Acdo.java @@ -0,0 +1,684 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_acdo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Acdo extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_acdo"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + static final String CLASS_AID_4 = "A0000000 090005FF FFFFFF89 50040001"; + static final String APPLET_AID_4 = "A0000000 090005FF FFFFFF89 50040102"; + static final String CLASS_AID_5 = "A0000000 090005FF FFFFFF89 50050001"; + static final String APPLET_AID_5 = "A0000000 090005FF FFFFFF89 50050102"; + static final String CLASS_AID_6 = "A0000000 090005FF FFFFFF89 50060001"; + static final String APPLET_AID_6 = "A0000000 090005FF FFFFFF89 50060102"; + static final String CLASS_AID_7 = "A0000000 090005FF FFFFFF89 50070001"; + static final String APPLET_AID_7 = "A0000000 090005FF FFFFFF89 50070102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Acdo() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + + + /*********************************************************************/ + /** Testcase 1 : Full access Applet */ + /*********************************************************************/ + + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00" + // LV Access Domain DAP field + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = Full Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0100" + // LV Access Domain for ADF1 file system = Full Access + "00"); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet1 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + /** Check Applet first results */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "4B" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + test.reset(); + test.terminalProfileSession("09010020"); + + // Trigger Applet1 on its menu 2 to launch admin fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "5A" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // delete applet + test.deleteApplet(APPLET_AID_1); + + + /*********************************************************************/ + /** Testcase 2 : No access Applet */ + /*********************************************************************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "01FF" + // LV Access Domain for UICC file system = No Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "01FF" + // LV Access Domain for ADF1 file system = No Access + "00" + // LV Access Domain DAP field + "8218" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "01FF" + // LV Access Domain for UICC file system = No Access + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "01FF" + // LV Access Domain for ADF1 file system = No Access + "00"); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // Trigger Applet2 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Check Applet first results */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "4B" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // Trigger Applet2 on its menu 2 to launch admin fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "5A" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // delete applet + test.deleteApplet(APPLET_AID_2); + + + /*********************************************************************/ + /** Testcase 3 : Always access right Applet */ + /*********************************************************************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402000004" + // LV Access Domain for UICC file system = Always access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402000004" + // LV Access Domain for ADF1 file system = Always access right + "00" + // LV Access Domain DAP field + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402000004" + // LV Access Domain for UICC file system = Always access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402000004" + // LV Access Domain for ADF1 file system = Always access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet3 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Check Applet first results */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "4B" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // Trigger Applet3 on its menu 2 to launch admin fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "5A" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applet + test.deleteApplet(APPLET_AID_3); + + + /*********************************************************************/ + /** Testcase 4 : Global PIN1 access right Applet */ + /*********************************************************************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_4, APPLET_AID_4, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402010000" + // LV Access Domain for UICC file system = Global PIN1 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402010000" + // LV Access Domain for ADF1 file system = Global PIN1 access right + "00" + // LV Access Domain DAP field + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402010000" + // LV Access Domain for UICC file system = Global PIN1 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402010000" + // LV Access Domain for ADF1 file system = Global PIN1 access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet4 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Check Applet first results */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "4B" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // Trigger Applet4 on its menu 2 to launch admin fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "5A" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applet + test.deleteApplet(APPLET_AID_4); + + + /*********************************************************************/ + /** Testcase 5 : Global PIN1 & ADM1 access right Applet */ + /*********************************************************************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_5, APPLET_AID_5, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402010100" + // LV Access Domain for UICC file system = Global PIN1 & ADM1 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402010100" + // LV Access Domain for ADF1 file system = Global PIN1 & ADM1 access right + "00" + // LV Access Domain DAP field + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402010100" + // LV Access Domain for UICC file system = Global PIN1 & ADM1 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402010100" + // LV Access Domain for ADF1 file system = Global PIN1 & ADM1 access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet5 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Check Applet first results */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_5); + result &= response.checkData("10" + APPLET_AID_5 + "4B" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // Trigger Applet5 on its menu 2 to launch admin fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_5); + result &= response.checkData("10" + APPLET_AID_5 + "5A" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applet + test.deleteApplet(APPLET_AID_5); + + + /*********************************************************************/ + /** Testcase 6 : Local PIN & ADM2 access right Applet */ + /*********************************************************************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_6, APPLET_AID_6, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402000208" + // LV Access Domain for UICC file system = Local PIN & ADM2 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402000208" + // LV Access Domain for ADF1 file system = Local PIN & ADM2 access right + "00" + // LV Access Domain DAP field + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402000208" + // LV Access Domain for UICC file system = Local PIN & ADM2 access right + "00" + // LV UICC File System AID field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402000208" + // LV Access Domain for ADF1 file system = Local PIN & ADM2 access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet6 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Check Applet first results */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_6); + result &= response.checkData("10" + APPLET_AID_6 + "4B" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + // Trigger Applet6 on its menu 2 to launch admin fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_6); + result &= response.checkData("10" + APPLET_AID_6 + "5A" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applet + test.deleteApplet(APPLET_AID_6); + + + + /*********************************************************************/ + /** Testcase 7 : Acces domain parameter differenciation */ + /*********************************************************************/ + + /** Subcase 1 **/ + /***************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_7, APPLET_AID_7, + "800E" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "03" + // V Id of menu entry 3 + "04" + // V Position of menu entry 3 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402000104" + // LV Access Domain for UICC file system = Always & ADM1 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402000104" + // LV Access Domain for ADF1 file system = Always & ADM1 access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet7 on its menu 2 to launch fileview access tests + response = test.envelopeMenuSelection("100101", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_7); + result &= response.checkData("10" + APPLET_AID_7 + "03" + "CCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applet + test.deleteApplet(APPLET_AID_7); + + /** Subcase 2 **/ + /***************/ + + test.installApplet( CAP_FILE_PATH, CLASS_AID_7, APPLET_AID_7, + "800E" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "03" + // V Id of menu entry 3 + "04" + // V Position of menu entry 3 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402010200" + // LV Access Domain for UICC file system = Global PIN1 & ADM2 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402010200" + // LV Access Domain for ADF1 file system = Global PIN1 & ADM2 access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet7 on its menu 2 to launch fileview access tests + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_7); + result &= response.checkData("10" + APPLET_AID_7 + "03" + "CCCCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applet + test.deleteApplet(APPLET_AID_7); + + /** Subcase 3 **/ + /***************/ + test.installApplet(CAP_FILE_PATH, CLASS_AID_7, APPLET_AID_7, + "800E" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "02" + // V Id of menu entry 2 + "02" + // V Position of menu entry 2 + "03" + // V Id of menu entry 3 + "03" + // V Position of menu entry 3 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "811E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402000104" + // LV Access Domain for UICC file system = Always & ADM1 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402000104" + // LV Access Domain for ADF1 file system = Always & ADM1 access right + "00" + // LV Access Domain DAP field + "821E" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0402010200" + // LV Access Domain for UICC file system = Global PIN1 & ADM2 access right + "00" + // LV Access Domain DAP field + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 File System AID field + "0402010200" + // LV Access Domain for ADF1 file system = Global PIN1 & ADM2 access right + "00" ); // LV Access Domain DAP field + // test script + test.reset(); + // Terminal Profile with Set Up Menu + test.terminalProfileSession("09010020"); + + + // Trigger Applet7 on its menu 1 to launch fileview access tests + response = test.envelopeMenuSelection("100103", ""); + result &= response.checkSw("9000"); + + /** Check Applet second results then delete it */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_7); + result &= response.checkData("10" + APPLET_AID_7 + "06" + + "CCCCCCCC CCCC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applet + test.deleteApplet(APPLET_AID_7); + + // Delete package + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9a29b71ee3f868d24cb387c990a81d6049875d75 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/applet.opt @@ -0,0 +1,10 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x04:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_4 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x07:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_7 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_1 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x05:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_5 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x06:0x00:0x01 uicc.test.catre.cre_tin_acdo.Cre_Tin_Acdo_6 +uicc.test.catre.cre_tin_acdo +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/javacard/cre_tin_acdo.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/javacard/cre_tin_acdo.cap new file mode 100644 index 0000000000000000000000000000000000000000..2a79ee8f10b4c8e8d711bd8dc00976be6e19b94b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_acdo/javacard/cre_tin_acdo.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_chal/Cre_Tin_Chal_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_chal/Cre_Tin_Chal_1.java new file mode 100644 index 0000000000000000000000000000000000000000..8908fa18288303258733576f9fb5c9033b92ffb3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_chal/Cre_Tin_Chal_1.java @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Chal_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_chal ; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Chal_1 extends TestToolkitApplet { + + /** + * Constructor of the applet + */ + public Cre_Tin_Chal_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Chal_1 thisApplet = new Cre_Tin_Chal_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_chal/Cre_Tin_Chal_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_chal/Cre_Tin_Chal_2.java new file mode 100644 index 0000000000000000000000000000000000000000..278de0af6522aebef3371db3dae7597880a09111 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_chal/Cre_Tin_Chal_2.java @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Chal_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_chal; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Chal_2 extends TestToolkitApplet { + + // Channel number to open + public final static short CHANNELS_NB = 4; + + static byte[] menu = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'2'}; + public final static byte QUALIFIER_1 = (byte)0x01; + public final static byte QUALIFIER_2 = (byte)0x02; + public static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + public static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + public static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Chal_2() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Chal_2 thisApplet = new Cre_Tin_Chal_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menu, (short)0, (short)menu.length, (byte)0, false, (byte) 0, (short) 0); + + // register instance with the EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS event + thisApplet.obReg.setEvent((short)EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + + + if (event == EVENT_MENU_SELECTION) { + + // -------------------------------------------- + // Test Case 3 : Open 4 channels + testCaseNb = (byte) 1 ; + + for (short i=0; i>4)&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + + c = (byte)(tab[ i ]&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + } + + return new String( tab2 ); + } + + // byte => String + private String ToString( byte myByte ) + { + byte[] tab; + byte c; + int i, j, k; + + tab = new byte[1]; + tab[0] = myByte; + + return ByteToString( tab ); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itid/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..69a638ba0447612c089edeb5cf13408ec54bf4fb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itid/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_itid.Cre_Tin_Itid_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_tin_itid.Cre_Tin_Itid_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_itid.Cre_Tin_Itid_1 +uicc.test.catre.cre_tin_itid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itid/javacard/cre_tin_itid.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itid/javacard/cre_tin_itid.cap new file mode 100644 index 0000000000000000000000000000000000000000..9f44ec5034f9c17be6ac1af2f23d52443b44f107 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itid/javacard/cre_tin_itid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_1.java new file mode 100644 index 0000000000000000000000000000000000000000..53d3c1c1025288abbcb9ddb46e467ab43647c7d6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_1.java @@ -0,0 +1,77 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Itpo_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo ; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.test.util.* ; + + + +public class Cre_Tin_Itpo_1 extends TestToolkitApplet +{ + static byte [] menuInit = {(byte) 'M', (byte) 'e', (byte) 'n', (byte) 'u', (byte) '1', (byte) '1'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Itpo_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Itpo_1 thisApplet = new Cre_Tin_Itpo_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + menuInit [5] = (byte) '2'; + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + menuInit [5] = (byte) '3'; + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + menuInit [5] = (byte) '4'; + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + // Get the envelope handler + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + if (event == EVENT_MENU_SELECTION) + { + switch (envHdlr.getItemIdentifier()) + { + case (byte)1: + obReg.disableMenuEntry((byte)1); + break; + case (byte)2: + obReg.enableMenuEntry((byte)1); + break; + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_2.java new file mode 100644 index 0000000000000000000000000000000000000000..aa764e31570050cdf878b1ee22106c49c5617ba7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_2.java @@ -0,0 +1,55 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Itpo_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo ; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Itpo_2 extends TestToolkitApplet +{ + static byte [] menuInit = {(byte) 'M', (byte) 'e', (byte) 'n', (byte) 'u', (byte) '2', (byte) '1'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Itpo_2() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Itpo_2 thisApplet = new Cre_Tin_Itpo_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_3.java new file mode 100644 index 0000000000000000000000000000000000000000..0a8c9ebb1bc4e58c4f6f7c261524a5a4c08ecd1f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_3.java @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Itpo_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo ; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Itpo_3 extends TestToolkitApplet +{ + static byte [] menuInit = {(byte) 'M', (byte) 'e', (byte) 'n', (byte) 'u', (byte) '3', (byte) '1'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Itpo_3() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Itpo_3 thisApplet = new Cre_Tin_Itpo_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + menuInit [5] = (byte) '2'; + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_4.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_4.java new file mode 100644 index 0000000000000000000000000000000000000000..61b184b297487cbf137b2d9bc36ce9533f145bc1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_4.java @@ -0,0 +1,53 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Itid_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Itpo_4 extends TestToolkitApplet +{ + static byte [] menuInit = {(byte) 'M', (byte) 'e', (byte) 'n', (byte) 'u', (byte) '4', (byte) '1'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Itpo_4() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Itpo_4 thisApplet = new Cre_Tin_Itpo_4(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE */ + public void processToolkit(short event) + { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_5.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_5.java new file mode 100644 index 0000000000000000000000000000000000000000..f296b526712c8dec4e8146b81d9196dba86f8172 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_5.java @@ -0,0 +1,53 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Itid_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Itpo_5 extends TestToolkitApplet +{ + static byte [] menuInit = {(byte) 'M', (byte) 'e', (byte) 'n', (byte) 'u', (byte) '5', (byte) '1'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Itpo_5() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Itpo_5 thisApplet = new Cre_Tin_Itpo_5(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE */ + public void processToolkit(short event) + { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_6.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_6.java new file mode 100644 index 0000000000000000000000000000000000000000..c6ebd555f62b5621508878d5c04c01da3584581c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Cre_Tin_Itpo_6.java @@ -0,0 +1,57 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Itid_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Itpo_6 extends TestToolkitApplet +{ + static byte [] menuInit = {(byte) 'M', (byte) 'e', (byte) 'n', (byte) 'u', (byte) '6', (byte) '1'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Itpo_6() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Itpo_6 thisApplet = new Cre_Tin_Itpo_6(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + menuInit [5] = (byte) '2'; + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + menuInit [5] = (byte) '3'; + thisApplet.obReg.initMenuEntry(menuInit, (short) 0, (short) 6, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE */ + public void processToolkit(short event) + { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Test_Cre_Tin_Itpo.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Test_Cre_Tin_Itpo.java new file mode 100644 index 0000000000000000000000000000000000000000..c56443bce3f66e2d56d0f2827836953261d45d39 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/Test_Cre_Tin_Itpo.java @@ -0,0 +1,517 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_itpo; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Itpo extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_itpo"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + static final String CLASS_AID_4 = "A0000000 090005FF FFFFFF89 50040001"; + static final String APPLET_AID_4 = "A0000000 090005FF FFFFFF89 50040102"; + static final String CLASS_AID_5 = "A0000000 090005FF FFFFFF89 50050001"; + static final String APPLET_AID_5 = "A0000000 090005FF FFFFFF89 50050102"; + static final String CLASS_AID_6 = "A0000000 090005FF FFFFFF89 50060001"; + static final String APPLET_AID_6 = "A0000000 090005FF FFFFFF89 50060102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Itpo() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + String[] menuList = new String[12]; + String[] menuIdList = new String[12]; + + // test script + test.reset(); + test.terminalProfileSession("09030020"); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8010" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "04" + // V Maximum number of menu entries + "01" + // V Position of menu entry 1 + "01" + // V Id of menu entry 1 + "02" + // V Position of menu entry 2 + "02" + // V Id of menu entry 2 + "03" + // V Position of menu entry 3 + "03" + // V Id of menu entry 3 + "04" + // V Position of menu entry 4 + "04" + // V Id of menu entry 4 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result = response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu11"; menuIdList[0] = "01"; + menuList[1] = "Menu12"; menuIdList[1] = "02"; + menuList[2] = "Menu13"; menuIdList[2] = "03"; + menuList[3] = "Menu14"; menuIdList[3] = "04"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)4, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Install Applet2 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Position of menu entry 1 + "05" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu11"; menuIdList[0] = "01"; + menuList[1] = "Menu12"; menuIdList[1] = "02"; + menuList[2] = "Menu21"; menuIdList[2] = "05"; + menuList[3] = "Menu13"; menuIdList[3] = "03"; + menuList[4] = "Menu14"; menuIdList[4] = "04"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)5, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Install Applet3 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800C" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "02" + // V Position of menu entry 1 + "06" + // V Id of menu entry 1 + "03" + // V Position of menu entry 2 + "07" + // V Id of menu entry 2 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu11"; menuIdList[0] = "01"; + menuList[1] = "Menu31"; menuIdList[1] = "06"; + menuList[2] = "Menu32"; menuIdList[2] = "07"; + menuList[3] = "Menu12"; menuIdList[3] = "02"; + menuList[4] = "Menu21"; menuIdList[4] = "05"; + menuList[5] = "Menu13"; menuIdList[5] = "03"; + menuList[6] = "Menu14"; menuIdList[6] = "04"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)7, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Install Applet4 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_4, APPLET_AID_4, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "00" + // V Position of menu entry 1 + "08" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu11"; menuIdList[0] = "01"; + menuList[1] = "Menu31"; menuIdList[1] = "06"; + menuList[2] = "Menu32"; menuIdList[2] = "07"; + menuList[3] = "Menu12"; menuIdList[3] = "02"; + menuList[4] = "Menu21"; menuIdList[4] = "05"; + menuList[5] = "Menu13"; menuIdList[5] = "03"; + menuList[6] = "Menu14"; menuIdList[6] = "04"; + menuList[7] = "Menu41"; menuIdList[7] = "08"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)8, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Install Applet5 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_5, APPLET_AID_5, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "20" + // V Position of menu entry 1 + "09" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu11"; menuIdList[0] = "01"; + menuList[1] = "Menu31"; menuIdList[1] = "06"; + menuList[2] = "Menu32"; menuIdList[2] = "07"; + menuList[3] = "Menu12"; menuIdList[3] = "02"; + menuList[4] = "Menu21"; menuIdList[4] = "05"; + menuList[5] = "Menu13"; menuIdList[5] = "03"; + menuList[6] = "Menu14"; menuIdList[6] = "04"; + menuList[7] = "Menu41"; menuIdList[7] = "08"; + menuList[8] = "Menu51"; menuIdList[8] = "09"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)9, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 6 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100101",""); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu31"; menuIdList[0] = "06"; + menuList[1] = "Menu32"; menuIdList[1] = "07"; + menuList[2] = "Menu12"; menuIdList[2] = "02"; + menuList[3] = "Menu21"; menuIdList[3] = "05"; + menuList[4] = "Menu13"; menuIdList[4] = "03"; + menuList[5] = "Menu14"; menuIdList[5] = "04"; + menuList[6] = "Menu41"; menuIdList[6] = "08"; + menuList[7] = "Menu51"; menuIdList[7] = "09"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)8, menuIdList, menuList, null, null); + + // Lock Applet2 + response = test.lockApplication(APPLET_AID_2); + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu31"; menuIdList[0] = "06"; + menuList[1] = "Menu32"; menuIdList[1] = "07"; + menuList[2] = "Menu12"; menuIdList[2] = "02"; + menuList[3] = "Menu13"; menuIdList[3] = "03"; + menuList[4] = "Menu14"; menuIdList[4] = "04"; + menuList[5] = "Menu41"; menuIdList[5] = "08"; + menuList[6] = "Menu51"; menuIdList[6] = "09"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)7, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 7 */ + /*********************************************************************/ + + // Install Applet6 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_6, APPLET_AID_6, + "800E" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "01" + // V Position of menu entry 1 + "10" + // V Id of menu entry 1 + "04" + // V Position of menu entry 2 + "11" + // V Id of menu entry 2 + "15" + // V Position of menu entry 3 + "12" + // V Id of menu entry 3 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu61"; menuIdList[0] = "10"; + menuList[1] = "Menu31"; menuIdList[1] = "06"; + menuList[2] = "Menu62"; menuIdList[2] = "11"; + menuList[3] = "Menu32"; menuIdList[3] = "07"; + menuList[4] = "Menu12"; menuIdList[4] = "02"; + menuList[5] = "Menu13"; menuIdList[5] = "03"; + menuList[6] = "Menu14"; menuIdList[6] = "04"; + menuList[7] = "Menu41"; menuIdList[7] = "08"; + menuList[8] = "Menu51"; menuIdList[8] = "09"; + menuList[9] = "Menu63"; menuIdList[9] = "12"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)10, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 8 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100102",""); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu61"; menuIdList[0] = "10"; + menuList[1] = "Menu11"; menuIdList[1] = "01"; + menuList[2] = "Menu31"; menuIdList[2] = "06"; + menuList[3] = "Menu62"; menuIdList[3] = "11"; + menuList[4] = "Menu32"; menuIdList[4] = "07"; + menuList[5] = "Menu12"; menuIdList[5] = "02"; + menuList[6] = "Menu13"; menuIdList[6] = "03"; + menuList[7] = "Menu14"; menuIdList[7] = "04"; + menuList[8] = "Menu41"; menuIdList[8] = "08"; + menuList[9] = "Menu51"; menuIdList[9] = "09"; + menuList[10] = "Menu63"; menuIdList[10] = "12"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)11, menuIdList, menuList, null, null); + + // Unlock Applet2 + response = test.unlockApplication(APPLET_AID_2); + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu61"; menuIdList[0] = "10"; + menuList[1] = "Menu11"; menuIdList[1] = "01"; + menuList[2] = "Menu31"; menuIdList[2] = "06"; + menuList[3] = "Menu62"; menuIdList[3] = "11"; + menuList[4] = "Menu32"; menuIdList[4] = "07"; + menuList[5] = "Menu12"; menuIdList[5] = "02"; + menuList[6] = "Menu21"; menuIdList[6] = "05"; + menuList[7] = "Menu13"; menuIdList[7] = "03"; + menuList[8] = "Menu14"; menuIdList[8] = "04"; + menuList[9] = "Menu41"; menuIdList[9] = "08"; + menuList[10] = "Menu51"; menuIdList[10] = "09"; + menuList[11] = "Menu63"; menuIdList[11] = "12"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)12, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 9 */ + /*********************************************************************/ + + // Delete Applet2 + response = test.deleteApplet(APPLET_AID_2); + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu61"; menuIdList[0] = "10"; + menuList[1] = "Menu11"; menuIdList[1] = "01"; + menuList[2] = "Menu31"; menuIdList[2] = "06"; + menuList[3] = "Menu62"; menuIdList[3] = "11"; + menuList[4] = "Menu32"; menuIdList[4] = "07"; + menuList[5] = "Menu12"; menuIdList[5] = "02"; + menuList[6] = "Menu13"; menuIdList[6] = "03"; + menuList[7] = "Menu14"; menuIdList[7] = "04"; + menuList[8] = "Menu41"; menuIdList[8] = "08"; + menuList[9] = "Menu51"; menuIdList[9] = "09"; + menuList[10] = "Menu63"; menuIdList[10] = "12"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)11, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + + // Install Applet2 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Position of menu entry 1 + "05" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Send a status command to be sure to retrieve the correct status word in the RAPDU + response = test.status("00","0C","00"); + result &= response.getStatusWord().substring(0,2).compareTo("91") == 0; + // Fetch & Terminal response + menuList[0] = "Menu61"; menuIdList[0] = "10"; + menuList[1] = "Menu11"; menuIdList[1] = "01"; + menuList[2] = "Menu21"; menuIdList[2] = "05"; + menuList[3] = "Menu31"; menuIdList[3] = "06"; + menuList[4] = "Menu62"; menuIdList[4] = "11"; + menuList[5] = "Menu32"; menuIdList[5] = "07"; + menuList[6] = "Menu12"; menuIdList[6] = "02"; + menuList[7] = "Menu13"; menuIdList[7] = "03"; + menuList[8] = "Menu14"; menuIdList[8] = "04"; + menuList[9] = "Menu41"; menuIdList[9] = "08"; + menuList[10] = "Menu51"; menuIdList[10] = "09"; + menuList[11] = "Menu63"; menuIdList[11] = "12"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)12, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deleteApplet(APPLET_AID_4); + test.deleteApplet(APPLET_AID_5); + test.deleteApplet(APPLET_AID_6); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } + + // Fetch a sepUpMenu command, check it according to the parameters + // and send the Terminal Response. + // Return true if the recieved command correspond to the one rebuild using + // the paramaters + private boolean fetchSetUpMenu( + String alphaId, // AlphaId TLV Value + String alphaIdTextAtt, // AlphaId Text Attribute TLV Value + byte nbMenu, // Number of menus + String[] menuId, // Menu Id List table + String[] menu, // Text Menu List table (in readable text!) + String nextActionTLV, // Next Action List TLV + String itemTextAttListTLV) // Item Text Attribute List TLV + { + boolean result; + String setUpMenuCmd = ""; + String endOfCmd = ""; + String Cmd = ""; + + // Build the Set Up Menu + if (nextActionTLV != null) + { + endOfCmd = nextActionTLV; + } + if (alphaIdTextAtt != null) + { + endOfCmd += "50" + ToString((byte)(alphaIdTextAtt.length()/2)) + alphaIdTextAtt; + } + if (itemTextAttListTLV != null) + { + endOfCmd += itemTextAttListTLV; + } + + String menuItem = ""; + String menuList = ""; + for (byte i = 0; i < nbMenu; i++) + { + menuItem = menuId[i]; + menuItem += ByteToString(menu[i].getBytes()); + menuList += "8F" + ToString((byte)(menuItem.length()/2)) + menuItem; + } + Cmd = menuList + endOfCmd; + + String alpId = ByteToString(alphaId.getBytes()); + setUpMenuCmd = "85" + ToString((byte)(alpId.length()/2)) + alpId; + setUpMenuCmd += Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "810301250082028182" + Cmd; + Cmd = setUpMenuCmd; + if ((Cmd.length()/2) > 0x7F) + { + setUpMenuCmd = "D081" + ToString((byte)(Cmd.length()/2)) + Cmd; + } + else + { + setUpMenuCmd = "D0" + ToString((byte)(Cmd.length()/2)) + Cmd; + } + + response = test.fetch(ToString((byte)(setUpMenuCmd.length()/2))); + result = response.checkData(setUpMenuCmd); + + test.terminalResponse("81030125 00820282 81830100"); + + return result; + } + + private String ByteToString( byte tab[] ) + { + byte[] tab2; + byte c; + int i, j, k; + + j = tab.length; + tab2 = new byte[ j*2]; + + k = 0; + for ( i=0; i>4)&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + + c = (byte)(tab[ i ]&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + } + + return new String( tab2 ); + } + + // byte => String + private String ToString( byte myByte ) + { + byte[] tab; + byte c; + int i, j, k; + + tab = new byte[1]; + tab[0] = myByte; + + return ByteToString( tab ); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6d81e9d8560da28a72be0cab7b8ded6cb133e819 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/applet.opt @@ -0,0 +1,9 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x04:0x00:0x01 uicc.test.catre.cre_tin_itpo.Cre_Tin_Itpo_4 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_itpo.Cre_Tin_Itpo_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_tin_itpo.Cre_Tin_Itpo_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_itpo.Cre_Tin_Itpo_1 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x05:0x00:0x01 uicc.test.catre.cre_tin_itpo.Cre_Tin_Itpo_5 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x06:0x00:0x01 uicc.test.catre.cre_tin_itpo.Cre_Tin_Itpo_6 +uicc.test.catre.cre_tin_itpo +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/javacard/cre_tin_itpo.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/javacard/cre_tin_itpo.cap new file mode 100644 index 0000000000000000000000000000000000000000..4151c7d9d51ff388aa6696adfb278eedce2495a1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_itpo/javacard/cre_tin_itpo.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/Cre_Tin_Mlme_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/Cre_Tin_Mlme_1.java new file mode 100644 index 0000000000000000000000000000000000000000..c1be655682bb6ce9819ebb851503b8b572925b6d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/Cre_Tin_Mlme_1.java @@ -0,0 +1,316 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Mlme_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_mlme; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Mlme_1 extends TestToolkitApplet +{ + + private static byte [] MenuEntry1 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) 'E', + (byte) 'n', + (byte) 't', + (byte) 'r', + (byte) 'y', + (byte) '1'}; + + private static byte [] MenuEntry2 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) 'E', + (byte) 'n', + (byte) 't', + (byte) 'r', + (byte) 'y', + (byte) '2'}; + + private static byte [] MenuEntry3 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) 'E', + (byte) 'n', + (byte) 't', + (byte) 'r', + (byte) 'y', + (byte) '3'}; + + private static byte [] MenuEntry03 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) 'E', + (byte) 'n', + (byte) 't', + (byte) 'r', + (byte) 'y', + (byte) '0', + (byte) '3'}; + + private static byte [] MenuEntry4 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) 'E', + (byte) 'n', + (byte) 't', + (byte) 'r', + (byte) 'y', + (byte) '4'}; + + private static byte [] MenuEntry05 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) 'E', + (byte) 'n', + (byte) 't', + (byte) 'r', + (byte) 'y', + (byte) '0', + (byte) '5'}; + + private byte result = (byte) 0; + + private byte testCaseNb = (byte)5; + + + + /** + * Constructor of the applet + */ + public Cre_Tin_Mlme_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + + // Create a new applet instance + Cre_Tin_Mlme_1 thisApplet = new Cre_Tin_Mlme_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + boolean bRes = true; + + // ----------------------------------------------------------------- + // Test Case 1 : 1- initMenuEntry()with parameters: + // MenuEntry = MenuEntry1 + // Offset = 0 + // Length = MenuEntry1.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + thisApplet.testCaseNb = (byte) 1; + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry1, (short) 0, + (short)MenuEntry1.length, (byte) 0, false, (byte) 0, (short) 0); + bRes = true; + } + + catch (Exception e) { + bRes = false; + } + + // ----------------------------------------------------------------- + // 2- initMenuEntry()with parameters: + // MenuEntry = MenuEntry2 + // Offset = 0 + // Length = MenuEntry2.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + + if (bRes == true) { + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry2, (short) 0, + (short)MenuEntry2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + catch (Exception e) { + bRes = false; + } + } + + thisApplet.reportTestOutcome(thisApplet.testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 2 : 1- initMenuEntry()with parameters: + // MenuEntry = MenuEntry03 + // Offset = 0 + // Length = MenuEntry03.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a ToolkitException.ALLOWED_LENGTH_EXCEEDED + // ----------------------------------------------------------------- + + thisApplet.testCaseNb = (byte)2; + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry03, (short) 0, + (short)MenuEntry03.length, (byte) 0, false, (byte) 0, (short) 0); + bRes = false; + } + + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.ALLOWED_LENGTH_EXCEEDED); + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(thisApplet.testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 3 : 1- initMenuEntry()with parameters: + // MenuEntry = MenuEntry3 + // Offset = 0 + // Length = MenuEntry3.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + + thisApplet.testCaseNb = (byte)3; + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry3, (byte) 0, + (short)MenuEntry3.length, (byte) 0, false, (byte) 0, (short) 0); + bRes = true; + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(thisApplet.testCaseNb, bRes) ; + } + + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + boolean bRes = true; + + + if (event == EVENT_MENU_SELECTION) { + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch (envHdlr.getItemIdentifier()) + { + case (byte)1: + // ----------------------------------------------------------------- + // Test Case 4 : 1- changeMenuEntry()with parameters: + // Id = 1 + // MenuEntry = MenuEntry4 + // Offset = 0 + // Length = MenuEntry4.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + + if ( testCaseNb == (byte)3 ) { + + testCaseNb = (byte)4; + try { + obReg.changeMenuEntry((byte)1, MenuEntry4, (short)0, (short)MenuEntry4.length, + (byte) 0, false, (byte) 0, (short) 0); + bRes = true; + } + + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + } + break; + case (byte)2: + // ----------------------------------------------------------------- + // Test Case 5 : 1- changeMenuEntry()with parameters: + // Id = 1 + // MenuEntry = MenuEntry05 + // Offset = 0 + // Length = MenuEntry05.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a ToolkitException.ALLOWED_LENGTH_EXCEEDED + // ----------------------------------------------------------------- + + if ( testCaseNb == (byte)4 ) { + + testCaseNb = (byte)5; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, MenuEntry05, (short)0, (short)MenuEntry05.length, + (byte) 0, false, (byte) 0, (short) 0); + } + + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.ALLOWED_LENGTH_EXCEEDED) { + bRes = true; + } + } + + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + } + break; + } + } + } +} + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/Test_Cre_Tin_Mlme.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/Test_Cre_Tin_Mlme.java new file mode 100644 index 0000000000000000000000000000000000000000..071ff0f2380f6fee1833ee9d7997b8bc1662a1a9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/Test_Cre_Tin_Mlme.java @@ -0,0 +1,212 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_mlme; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Mlme extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_mlme"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Mlme() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + String[] menuList = new String[3]; + String[] menuIdList = new String[3]; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1-3 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800E" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "01" + // V Position of menu entry 1 + "01" + // V Id of menu entry 1 + "02" + // V Position of menu entry 2 + "02" + // V Id of menu entry 2 + "03" + // V Position of menu entry 3 + "03" + // V Id of menu entry 3 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfile("09030020"); + // Fetch & Terminal response + menuList[0] = "MenuEntry1"; menuIdList[0] = "01"; + menuList[1] = "MenuEntry2"; menuIdList[1] = "02"; + menuList[2] = "MenuEntry3"; menuIdList[2] = "03"; + result = fetchSetUpMenu("UICC TEST", null, (byte)3, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Trigger Applet1 + test.envelopeMenuSelection("100101",""); + + // Fetch & Terminal response + menuList[0] = "MenuEntry4"; menuIdList[0] = "01"; + menuList[1] = "MenuEntry2"; menuIdList[1] = "02"; + menuList[2] = "MenuEntry3"; menuIdList[2] = "03"; + result = fetchSetUpMenu("UICC TEST", null, (byte)3, menuIdList, menuList, null, null); + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Trigger Applet1 + response = test.envelopeMenuSelection("100102",""); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05" + "CCCCCCCC CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } + + // Fetch a sepUpMenu command, check it according to the parameters + // and send the Terminal Response. + // Return true if the recieved command correspond to the one rebuild using + // the paramaters + private boolean fetchSetUpMenu( + String alphaId, // AlphaId TLV Value + String alphaIdTextAtt, // AlphaId Text Attribute TLV Value + byte nbMenu, // Number of menus + String[] menuId, // Menu Id List table + String[] menu, // Text Menu List table (in readable text!) + String nextActionTLV, // Next Action List TLV + String itemTextAttListTLV) // Item Text Attribute List TLV + { + boolean result; + String setUpMenuCmd = ""; + String endOfCmd = ""; + String Cmd = ""; + + // Build the Set Up Menu + if (nextActionTLV != null) + { + endOfCmd = nextActionTLV; + } + if (alphaIdTextAtt != null) + { + endOfCmd += "50" + ToString((byte)(alphaIdTextAtt.length()/2)) + alphaIdTextAtt; + } + if (itemTextAttListTLV != null) + { + endOfCmd += itemTextAttListTLV; + } + + String menuItem = ""; + String menuList = ""; + for (byte i = 0; i < nbMenu; i++) + { + menuItem = menuId[i]; + menuItem += ByteToString(menu[i].getBytes()); + menuList += "8F" + ToString((byte)(menuItem.length()/2)) + menuItem; + } + Cmd = menuList + endOfCmd; + + String alpId = ByteToString(alphaId.getBytes()); + setUpMenuCmd = "85" + ToString((byte)(alpId.length()/2)) + alpId; + setUpMenuCmd += Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "810301250082028182" + Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "D0" + ToString((byte)(Cmd.length()/2)) + Cmd; + + response = test.fetch(ToString((byte)(setUpMenuCmd.length()/2))); + result = response.checkData(setUpMenuCmd); + + test.terminalResponse("81030125 00820282 81830100"); + + return result; + } + + private String ByteToString( byte tab[] ) + { + byte[] tab2; + byte c; + int i, j, k; + + j = tab.length; + tab2 = new byte[ j*2]; + + k = 0; + for ( i=0; i>4)&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + + c = (byte)(tab[ i ]&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + } + + return new String( tab2 ); + } + + // byte => String + private String ToString( byte myByte ) + { + byte[] tab; + byte c; + int i, j, k; + + tab = new byte[1]; + tab[0] = myByte; + + return ByteToString( tab ); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..332c432523f6707d0d33fafed41c70e05c821892 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_mlme.Cre_Tin_Mlme_1 +uicc.test.catre.cre_tin_mlme +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/javacard/cre_tin_mlme.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/javacard/cre_tin_mlme.cap new file mode 100644 index 0000000000000000000000000000000000000000..1ad045d37863562cfa8a7e2426bdfe75f052375b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_mlme/javacard/cre_tin_mlme.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Cre_Tin_Nbme_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Cre_Tin_Nbme_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7dfa1c18e860a33a7b93de1b2d99ed6c255b3283 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Cre_Tin_Nbme_1.java @@ -0,0 +1,182 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Nbme_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_nbme; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Nbme_1 extends TestToolkitApplet +{ + public static byte [] MenuEntry1 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '1' }; + + public static byte [] MenuEntry2 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '2' }; + + public static byte [] MenuEntry3 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '3' }; + + public static byte [] MenuEntry4 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '4' }; + + /** + * Constructor of the applet + */ + + public Cre_Tin_Nbme_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + boolean bRes = true; + byte result = (byte) 0; + byte testCaseNb = (byte)1; + + + // Create a new applet instance + Cre_Tin_Nbme_1 thisApplet = new Cre_Tin_Nbme_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // ----------------------------------------------------------------- + // Test Case 1 : 1- initMenuEntry()with parameters: + // MenuEntry = Menu1 + // Offset = 0 + // Length = Menu1.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + result = thisApplet.obReg.initMenuEntry(MenuEntry1, (byte) 0, + (short)MenuEntry1.length, (byte) 0, false, (byte) 0, (short) 0); + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte)2; + + // ----------------------------------------------------------------- + // 2- initMenuEntry()with parameters: + // MenuEntry = Menu2 + // Offset = 0 + // Length = Menu2.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + result = thisApplet.obReg.initMenuEntry(MenuEntry2, (byte) 0, + (short)MenuEntry2.length, (byte) 0, false, (byte) 0, (short) 0); + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte)3; + + // ----------------------------------------------------------------- + // 3- initMenuEntry()with parameters: + // MenuEntry = Menu3 + // Offset = 0 + // Length = Menu3.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + result = thisApplet.obReg.initMenuEntry(MenuEntry3, (byte) 0, + (short)MenuEntry3.length, (byte) 0, false, (byte) 0, (short) 0); + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(testCaseNb, bRes); + testCaseNb = (byte)4; + + // ----------------------------------------------------------------- + // Test Case 2 : initMenuEntry()with parameters: + // MenuEntry = Menu4 + // Offset = 0 + // Length = Menu4.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a ToolkitException.REGISTRY_ERROR + // ----------------------------------------------------------------- + try { + result = thisApplet.obReg.initMenuEntry(MenuEntry4, (byte) 0, + (short)MenuEntry4.length, (byte) 0, false, (byte) 0, (short) 0); + } + + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.REGISTRY_ERROR); + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(testCaseNb, bRes); + testCaseNb++; + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Cre_Tin_Nbme_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Cre_Tin_Nbme_2.java new file mode 100644 index 0000000000000000000000000000000000000000..3a00704d52016bb7e56881fec0f7957af625bca7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Cre_Tin_Nbme_2.java @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Nbme_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_nbme; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Nbme_2 extends TestToolkitApplet +{ + public static byte [] MenuEntry1 = + {(byte) 'M', + (byte) 'e', + (byte) 'n', + (byte) 'u', + (byte) '5' }; + /** + * Constructor of the applet + */ + + public Cre_Tin_Nbme_2() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + boolean bRes = false; + byte result = (byte) 0; + byte testCaseNb = (byte)1; + + + // Create a new applet instance + Cre_Tin_Nbme_2 thisApplet = new Cre_Tin_Nbme_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // ----------------------------------------------------------------- + // Test Case 3 : initMenuEntry()with parameters: + // MenuEntry = Menu1 + // Offset = 0 + // Length = Menu1.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a ToolkitException.REGISTRY_ERROR + // ----------------------------------------------------------------- + try { + result = thisApplet.obReg.initMenuEntry(Cre_Tin_Nbme_2.MenuEntry1, (byte) 0, + (short)Cre_Tin_Nbme_2.MenuEntry1.length, (byte) 0, false, (byte) 0, (short) 0); + } + + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.REGISTRY_ERROR); + } + + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(testCaseNb, bRes); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Test_Cre_Tin_Nbme.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Test_Cre_Tin_Nbme.java new file mode 100644 index 0000000000000000000000000000000000000000..8ad2a07da67d17bbc9b94af734bcecf503df4b9c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/Test_Cre_Tin_Nbme.java @@ -0,0 +1,223 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_nbme; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Nbme extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_nbme"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Nbme() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + String[] menuList = new String[3]; + String[] menuIdList = new String[3]; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Card Initialisation + test.reset(); + test.terminalProfile("09030020"); + + /*********************************************************************/ + /** Testcase 1-2 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800E" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "03" + // V Maximum number of menu entries + "01" + // V Position of menu entry 1 + "01" + // V Id of menu entry 1 + "02" + // V Position of menu entry 2 + "02" + // V Id of menu entry 2 + "03" + // V Position of menu entry 3 + "03" + // V Id of menu entry 3 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Fetch & Terminal response + menuList[0] = "Menu1"; menuIdList[0] = "01"; + menuList[1] = "Menu2"; menuIdList[1] = "02"; + menuList[2] = "Menu3"; menuIdList[2] = "03"; + result = fetchSetUpMenu("UICC TEST", null, (byte)3, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfile("09030020"); + + // Fetch & Terminal response + menuList[0] = "Menu1"; menuIdList[0] = "01"; + menuList[1] = "Menu2"; menuIdList[1] = "02"; + menuList[2] = "Menu3"; menuIdList[2] = "03"; + result &= fetchSetUpMenu("UICC TEST", null, (byte)3, menuIdList, menuList, null, null); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04" + "CCCCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } + + // Fetch a sepUpMenu command, check it according to the parameters + // and send the Terminal Response. + // Return true if the recieved command correspond to the one rebuild using + // the paramaters + private boolean fetchSetUpMenu( + String alphaId, // AlphaId TLV Value + String alphaIdTextAtt, // AlphaId Text Attribute TLV Value + byte nbMenu, // Number of menus + String[] menuId, // Menu Id List table + String[] menu, // Text Menu List table (in readable text!) + String nextActionTLV, // Next Action List TLV + String itemTextAttListTLV) // Item Text Attribute List TLV + { + boolean result; + String setUpMenuCmd = ""; + String endOfCmd = ""; + String Cmd = ""; + + // Build the Set Up Menu + if (nextActionTLV != null) + { + endOfCmd = nextActionTLV; + } + if (alphaIdTextAtt != null) + { + endOfCmd += "50" + ToString((byte)(alphaIdTextAtt.length()/2)) + alphaIdTextAtt; + } + if (itemTextAttListTLV != null) + { + endOfCmd += itemTextAttListTLV; + } + + String menuItem = ""; + String menuList = ""; + for (byte i = 0; i < nbMenu; i++) + { + menuItem = menuId[i]; + menuItem += ByteToString(menu[i].getBytes()); + menuList += "8F" + ToString((byte)(menuItem.length()/2)) + menuItem; + } + Cmd = menuList + endOfCmd; + + String alpId = ByteToString(alphaId.getBytes()); + setUpMenuCmd = "85" + ToString((byte)(alpId.length()/2)) + alpId; + setUpMenuCmd += Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "810301250082028182" + Cmd; + Cmd = setUpMenuCmd; + setUpMenuCmd = "D0" + ToString((byte)(Cmd.length()/2)) + Cmd; + + response = test.fetch(ToString((byte)(setUpMenuCmd.length()/2))); + result = response.checkData(setUpMenuCmd); + + test.terminalResponse("81030125 00820282 81830100"); + + return result; + } + + private String ByteToString( byte tab[] ) + { + byte[] tab2; + byte c; + int i, j, k; + + j = tab.length; + tab2 = new byte[ j*2]; + + k = 0; + for ( i=0; i>4)&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + + c = (byte)(tab[ i ]&15); + tab2[ k++ ] = (c>9) ? (byte)(c-10+'A') : (byte)(c+'0'); + } + + return new String( tab2 ); + } + + // byte => String + private String ToString( byte myByte ) + { + byte[] tab; + byte c; + int i, j, k; + + tab = new byte[1]; + tab[0] = myByte; + + return ByteToString( tab ); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b8e1e699c1dcffb3291434f77a524d7ef54e0e8d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_nbme.Cre_Tin_Nbme_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_nbme.Cre_Tin_Nbme_1 +uicc.test.catre.cre_tin_nbme +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/javacard/cre_tin_nbme.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/javacard/cre_tin_nbme.cap new file mode 100644 index 0000000000000000000000000000000000000000..9794d09068150435b6bcbcc059a01e8478f9c4da Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_nbme/javacard/cre_tin_nbme.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/Cre_Tin_Prlv_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/Cre_Tin_Prlv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3f24d93087695c8540d50e2dfcacb0ddfd97e714 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/Cre_Tin_Prlv_1.java @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_1; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_1 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_1() + { + Cre_Tin_Prlv_1.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_1 thisApplet = new Cre_Tin_Prlv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/Test_Cre_Tin_Prlv_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/Test_Cre_Tin_Prlv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b7010fc9c34c7aa3ecb07ea41357249aaa491c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/Test_Cre_Tin_Prlv_1.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_1; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_1 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_1"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_1() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3754f0d5c8723a3e75f91b7ce878d114e9a3c631 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_1.Cre_Tin_Prlv_1 +uicc.test.catre.cre_tin_prlv_1 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/javacard/cre_tin_prlv_1.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/javacard/cre_tin_prlv_1.cap new file mode 100644 index 0000000000000000000000000000000000000000..fc0363bfa6298b32774cf48deb31d65f9336455f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_1/javacard/cre_tin_prlv_1.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/Cre_Tin_Prlv_10.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/Cre_Tin_Prlv_10.java new file mode 100644 index 0000000000000000000000000000000000000000..24a9277bfb7310bd0be7b1c6c2f6a2250712d8d8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/Cre_Tin_Prlv_10.java @@ -0,0 +1,29 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_10.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_10; + + + +public class Cre_Tin_Prlv_10 +{ + + public static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_10() + { + + } + + +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/Test_Cre_Tin_Prlv_10.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/Test_Cre_Tin_Prlv_10.java new file mode 100644 index 0000000000000000000000000000000000000000..93ec866c69d596a51a62c0832c0158b857be7976 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/Test_Cre_Tin_Prlv_10.java @@ -0,0 +1,167 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_10; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_10 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_10"; + static final String CAP_FILE_PATH_A = "uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a"; + static final String CAP_FILE_PATH_B = "uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b"; + static final String CLASS_AID_A = "A0000000 090005FF FFFFFF89 50110001"; + static final String APPLET_AID_A1 = "A0000000 090005FF FFFFFF89 50110102"; + static final String APPLET_AID_A2 = "A0000000 090005FF FFFFFF89 50110202"; + static final String CLASS_AID_B = "A0000000 090005FF FFFFFF89 50210001"; + static final String APPLET_AID_B1 = "A0000000 090005FF FFFFFF89 50210102"; + static final String APPLET_AID_B2 = "A0000000 090005FF FFFFFF89 50210202"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_10() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install packages + test.loadPackage(CAP_FILE_PATH); + test.loadPackage(CAP_FILE_PATH_A); + test.loadPackage(CAP_FILE_PATH_B); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install AppletA1 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A, APPLET_AID_A1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install AppletA2 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A, APPLET_AID_A2, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_A1); + result &= response.checkData("10" + APPLET_AID_A1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_A2); + result &= response.checkData("10" + APPLET_AID_A2 + "01" + "CC"); + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install AppletB1 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B, APPLET_AID_B1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install AppletB2 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B, APPLET_AID_B2, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_A1); + result &= response.checkData("10" + APPLET_AID_A1 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_A2); + result &= response.checkData("10" + APPLET_AID_A2 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_B1); + result &= response.checkData("10" + APPLET_AID_B1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_B2); + result &= response.checkData("10" + APPLET_AID_B2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_A1); + test.deleteApplet(APPLET_AID_A2); + test.deleteApplet(APPLET_AID_B1); + test.deleteApplet(APPLET_AID_B2); + test.deletePackage(CAP_FILE_PATH_B); + test.deletePackage(CAP_FILE_PATH_A); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..067564a87fe47c366682ac6af8ac73ed8f0944af --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/applet.opt @@ -0,0 +1,3 @@ +-out EXP CAP JCA +uicc.test.catre.cre_tin_prlv_10 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/Cre_Tin_Prlv_10A.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/Cre_Tin_Prlv_10A.java new file mode 100644 index 0000000000000000000000000000000000000000..5181ee8e87ac2114e7e725e768d3cb14e3e2e28b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/Cre_Tin_Prlv_10A.java @@ -0,0 +1,152 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_10A.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_10.cre_tin_prlv_10a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; +import uicc.test.catre.cre_tin_prlv_10.Cre_Tin_Prlv_10 ; + + + +public class Cre_Tin_Prlv_10A extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private byte bMyInstanceId ; + private static byte bNbCall = (byte)1; // number of triggering calls of the applet + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_10A() + { + Cre_Tin_Prlv_10A.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Prlv_10A thisApplet = new Cre_Tin_Prlv_10A(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + Cre_Tin_Prlv_10.bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)1: + // --------------------------------------------------------- + // First call with only this package applets installed, Execution in 1st place + // --------------------------------------------------------- + switch ( bNbCall ) { + + case (byte)1: + if ( Cre_Tin_Prlv_10.bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // --------------------------------------------------------- + // Second call with all applets installed, Execution in 2nd place + // --------------------------------------------------------- + case (byte)2: + if ( Cre_Tin_Prlv_10.bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)2, true) ; + } + else { + reportTestOutcome((byte)2, false) ; + } + break; + + default: + break; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)2: + // --------------------------------------------------------- + // First call with only this package applets installed, Execution in 2nd place + // --------------------------------------------------------- + switch ( bNbCall ) { + + case (byte)1: + + if ( Cre_Tin_Prlv_10.bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + + bNbCall = (byte)2 ; + Cre_Tin_Prlv_10.bNbInstanceTriggered = (byte)0 ; + + break; + + // --------------------------------------------------------- + // Second call with all applets installed, Execution in 4th place + // --------------------------------------------------------- + case (byte)2: + + if ( Cre_Tin_Prlv_10.bNbInstanceTriggered == (byte)4 ) { + reportTestOutcome((byte)2, true) ; + } + else { + reportTestOutcome((byte)2, false) ; + } + break; + + default: + break; + } + + break; + + default: + reportTestOutcome ((byte)1, false); + break; + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..dbd90c8f82098be7a0ba4978979d4f544c7667ed --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x11:0x00:0x01 uicc.test.catre.cre_tin_prlv_10.cre_tin_prlv_10a.Cre_Tin_Prlv_10A +uicc.test.catre.cre_tin_prlv_10.cre_tin_prlv_10a +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x10:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/javacard/cre_tin_prlv_10a.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/javacard/cre_tin_prlv_10a.cap new file mode 100644 index 0000000000000000000000000000000000000000..703787f16de34e66be160807741cf6e79d05ccfc Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10a/javacard/cre_tin_prlv_10a.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/Cre_Tin_Prlv_10B.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/Cre_Tin_Prlv_10B.java new file mode 100644 index 0000000000000000000000000000000000000000..739cb0d3f0b38323870cd94c5e1df57d245db142 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/Cre_Tin_Prlv_10B.java @@ -0,0 +1,99 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_10B.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_10.cre_tin_prlv_10b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; +import uicc.test.catre.cre_tin_prlv_10.Cre_Tin_Prlv_10 ; + + + +public class Cre_Tin_Prlv_10B extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_10B() + { + Cre_Tin_Prlv_10B.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Prlv_10B thisApplet = new Cre_Tin_Prlv_10B(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + Cre_Tin_Prlv_10.bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 3 execution, Priority Level 1, Execution in 1st place + // ----------------------------------------------------------------- + + case (byte)1: + if ( Cre_Tin_Prlv_10.bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 4 execution, Priority Level 2, Execution in 3rd place + // ----------------------------------------------------------------- + + case (byte)2: + if ( Cre_Tin_Prlv_10.bNbInstanceTriggered == (byte)3 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..001532ca188095e45d2575343027fdd2c1d65e3e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x21:0x00:0x01 uicc.test.catre.cre_tin_prlv_10.cre_tin_prlv_10b.Cre_Tin_Prlv_10B +uicc.test.catre.cre_tin_prlv_10.cre_tin_prlv_10b +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x20:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/javacard/cre_tin_prlv_10b.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/javacard/cre_tin_prlv_10b.cap new file mode 100644 index 0000000000000000000000000000000000000000..6a81935b773f49bced55b26877b0ca7f66dfa70a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/cre_tin_prlv_10b/javacard/cre_tin_prlv_10b.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/javacard/cre_tin_prlv_10.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/javacard/cre_tin_prlv_10.cap new file mode 100644 index 0000000000000000000000000000000000000000..33c4c38411212c60606f6edbfa4c93588363f70f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_10/javacard/cre_tin_prlv_10.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/Cre_Tin_Prlv_11.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/Cre_Tin_Prlv_11.java new file mode 100644 index 0000000000000000000000000000000000000000..34ccf59523e91a954f1a66c6835607c590dba11b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/Cre_Tin_Prlv_11.java @@ -0,0 +1,191 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_11.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_11; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_11 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private static byte bNbCall = (byte)1 ; // number of triggering calls of the applet + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_11() + { + Cre_Tin_Prlv_11.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_11 thisApplet = new Cre_Tin_Prlv_11(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)1: + + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 4th + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)4) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 3th + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)3) && (bNbCall == (byte)2) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 2nd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)2) && (bNbCall == (byte)3) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + } + + bNbCall ++ ; + bNbInstanceTriggered = (byte)0 ; + + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)2: + + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 3rd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)3) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 2nd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)2) && (bNbCall == (byte)2) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 1st + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)1) && (bNbCall == (byte)3) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + } + + break; + + // ----------------------------------------------------------------- + // Instance 3 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)3: + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 2nd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)2) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 1st + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)1) && (bNbCall == (byte)2) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + + break; + + // ----------------------------------------------------------------- + // Instance 4 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)4: + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 1st + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)1) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/Test_Cre_Tin_Prlv_11.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/Test_Cre_Tin_Prlv_11.java new file mode 100644 index 0000000000000000000000000000000000000000..9211fec2d05de6ed94d5c098f9897917ce132df1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/Test_Cre_Tin_Prlv_11.java @@ -0,0 +1,188 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_11; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_11 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_11"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50010302"; + static final String APPLET_AID_4 = "A0000000 090005FF FFFFFF89 50010402"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_11() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install packages + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet4 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_4, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "01" + "CC"); + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // delete Applet4 + test.deleteApplet(APPLET_AID_4); + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "02" + "CCCC"); + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // delete Applet4 + test.deleteApplet(APPLET_AID_3); + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "03" + "CCCCCC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "03" + "CCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..da5bf6bad2581e98df3c71b12099836b989a70b9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_11.Cre_Tin_Prlv_11 +uicc.test.catre.cre_tin_prlv_11 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/javacard/cre_tin_prlv_11.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/javacard/cre_tin_prlv_11.cap new file mode 100644 index 0000000000000000000000000000000000000000..90c593cea2f8ff1864324af9ecb02fdf1bac85a1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_11/javacard/cre_tin_prlv_11.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/Cre_Tin_Prlv_12.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/Cre_Tin_Prlv_12.java new file mode 100644 index 0000000000000000000000000000000000000000..875f626314f123236ca0f10d07b8b3890b14e903 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/Cre_Tin_Prlv_12.java @@ -0,0 +1,246 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_12.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_12; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_12 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private static byte bNbCall = (byte)1 ; // number of triggering calls of the applet + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_12() + { + + Cre_Tin_Prlv_12.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + + // after 5 calls, call the first applet again --> re initialize instance number + if (bNbInstance == (byte)5) { + bNbInstance = (byte)0; + } + + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Prlv_12 thisApplet = new Cre_Tin_Prlv_12(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)1: + + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 2nd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)2) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is not installed + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 1st + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)1) && (bNbCall == (byte)3) ) { + reportTestOutcome((byte)(bNbCall-2), true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)2: + + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 4th + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)4) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 4th + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)4) && (bNbCall == (byte)2) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 5th + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)5) && (bNbCall == (byte)3) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + } + + bNbCall ++ ; + bNbInstanceTriggered = (byte)0 ; + + break; + + // ----------------------------------------------------------------- + // Instance 3 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)3: + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 1st + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)1) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 1st + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)1) && (bNbCall == (byte)2) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 2nd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)2) && (bNbCall == (byte)3) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + } + + break; + + // ----------------------------------------------------------------- + // Instance 4 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)4: + // --------------------------------------------------------- + // For the 1st call, this instance is triggered 3rd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)3) && (bNbCall == (byte)1) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 3rd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)3) && (bNbCall == (byte)2) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 4th + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)4) && (bNbCall == (byte)3) ) { + reportTestOutcome(bNbCall, true) ; + } + else { + reportTestOutcome(bNbCall, false) ; + } + } + } + + break; + + // ----------------------------------------------------------------- + // Instance 5 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)5: + // --------------------------------------------------------- + // For the 1st call, this instance is not installed + // --------------------------------------------------------- + // For the 2nd call, this instance is triggered 2nd + // --------------------------------------------------------- + + if ( (bNbInstanceTriggered == (byte)2) && (bNbCall == (byte)2) ) { + reportTestOutcome((byte)(bNbCall-1), true) ; + } + else { + + // --------------------------------------------------------- + // For the 3rd call, this instance is triggered 3rd + // --------------------------------------------------------- + if ( (bNbInstanceTriggered == (byte)3) && (bNbCall == (byte)3) ) { + reportTestOutcome((byte)(bNbCall-1), true) ; + } + else { + reportTestOutcome((byte)(bNbCall-1), false) ; + } + } + + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/Test_Cre_Tin_Prlv_12.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/Test_Cre_Tin_Prlv_12.java new file mode 100644 index 0000000000000000000000000000000000000000..613b4b83e8112dd7b0f1c41c7587d0a109e8dc5d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/Test_Cre_Tin_Prlv_12.java @@ -0,0 +1,223 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_12; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_12 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_12"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50010302"; + static final String APPLET_AID_4 = "A0000000 090005FF FFFFFF89 50010402"; + static final String APPLET_AID_5 = "A0000000 090005FF FFFFFF89 50010502"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_12() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + String[] menuList = new String[3]; + String[] menuIdList = new String[3]; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install packages + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet4 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_4, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "01" + "CC"); + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // delete Applet1 + test.deleteApplet(APPLET_AID_1); + + // Install Applet5 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_5, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_5); + result &= response.checkData("10" + APPLET_AID_5 + "01" + "CC"); + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "03" + "CCCCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "03" + "CCCCCC"); + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "03" + "CCCCCC"); + response = test.selectApplication(APPLET_AID_5); + result &= response.checkData("10" + APPLET_AID_5 + "02" + "CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deleteApplet(APPLET_AID_4); + test.deleteApplet(APPLET_AID_5); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..55c2faf484c715f7ea36347d07e8badd3a4b3adf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_12.Cre_Tin_Prlv_12 +uicc.test.catre.cre_tin_prlv_12 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/javacard/cre_tin_prlv_12.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/javacard/cre_tin_prlv_12.cap new file mode 100644 index 0000000000000000000000000000000000000000..ff1fb5bd5d203a67673d380f2670f565786bae45 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_12/javacard/cre_tin_prlv_12.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/Cre_Tin_Prlv_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/Cre_Tin_Prlv_2.java new file mode 100644 index 0000000000000000000000000000000000000000..19830cbc1e657fe80fbc3f008ae7197790f979c5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/Cre_Tin_Prlv_2.java @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------------- +// FWK_TIN_PRLV_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_2; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.*; + + + +public class Cre_Tin_Prlv_2 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_2() + { + Cre_Tin_Prlv_2.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_2 thisApplet = new Cre_Tin_Prlv_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/Test_Cre_Tin_Prlv_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/Test_Cre_Tin_Prlv_2.java new file mode 100644 index 0000000000000000000000000000000000000000..d5e617ed6483ac516a3e2633033cea1cd8979d16 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/Test_Cre_Tin_Prlv_2.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_2; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_2 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_2"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_2() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..e2294eb4aed05c278c53e4d055594e779fca3721 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_2.Cre_Tin_Prlv_2 +uicc.test.catre.cre_tin_prlv_2 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/javacard/cre_tin_prlv_2.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/javacard/cre_tin_prlv_2.cap new file mode 100644 index 0000000000000000000000000000000000000000..4540320c910b662d28ea59b4cc92d393df483cb7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_2/javacard/cre_tin_prlv_2.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/Cre_Tin_Prlv_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/Cre_Tin_Prlv_3.java new file mode 100644 index 0000000000000000000000000000000000000000..661da90d5f8657d8185613bcd7feac3012d8629b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/Cre_Tin_Prlv_3.java @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_3; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_3 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_3() + { + Cre_Tin_Prlv_3.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_3 thisApplet = new Cre_Tin_Prlv_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 80 + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 7F + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/Test_Cre_Tin_Prlv_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/Test_Cre_Tin_Prlv_3.java new file mode 100644 index 0000000000000000000000000000000000000000..55cedc3e186f84acadcdbd413507eb007a896045 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/Test_Cre_Tin_Prlv_3.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_3; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_3 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_3"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_3() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "80" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "7F" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..e9fc0eb34ed90df59abe970245202039932372fd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_3.Cre_Tin_Prlv_3 +uicc.test.catre.cre_tin_prlv_3 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/javacard/cre_tin_prlv_3.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/javacard/cre_tin_prlv_3.cap new file mode 100644 index 0000000000000000000000000000000000000000..f6172247655ee6d6b6a820305f22c626245e2b9c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_3/javacard/cre_tin_prlv_3.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/Cre_Tin_Prlv_4.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/Cre_Tin_Prlv_4.java new file mode 100644 index 0000000000000000000000000000000000000000..484f27f54a34655266968b3e6ff2501e3cdc810e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/Cre_Tin_Prlv_4.java @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_4.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_4; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_4 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_4() + { + Cre_Tin_Prlv_4.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_4 thisApplet = new Cre_Tin_Prlv_4(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 7F + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 80 + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/Test_Cre_Tin_Prlv_4.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/Test_Cre_Tin_Prlv_4.java new file mode 100644 index 0000000000000000000000000000000000000000..a538f5760c1fe1b756252eeb3d96fb2ec297799b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/Test_Cre_Tin_Prlv_4.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_4; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_4 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_4"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_4() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "7F" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "80" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4d0d323a45a9a3eb53bb7b2a7afe160e9d2f0b52 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_4.Cre_Tin_Prlv_4 +uicc.test.catre.cre_tin_prlv_4 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/javacard/cre_tin_prlv_4.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/javacard/cre_tin_prlv_4.cap new file mode 100644 index 0000000000000000000000000000000000000000..4e5bc59a8680016974c72b855104f0816609e9d2 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_4/javacard/cre_tin_prlv_4.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/Cre_Tin_Prlv_5.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/Cre_Tin_Prlv_5.java new file mode 100644 index 0000000000000000000000000000000000000000..1dadcba899d08430c6f1dec33b3242e9b94a110a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/Cre_Tin_Prlv_5.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_5.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_5; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_5 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_5() + { + Cre_Tin_Prlv_5.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_5 thisApplet = new Cre_Tin_Prlv_5(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)3 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 3 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)3: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/Test_Cre_Tin_Prlv_5.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/Test_Cre_Tin_Prlv_5.java new file mode 100644 index 0000000000000000000000000000000000000000..49cbc356fb9ab002ba6ab091de6dd8338b4adcee --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/Test_Cre_Tin_Prlv_5.java @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_5; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_5 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_5"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50010202"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50010302"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_5() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_3, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b79612951dacff7cda865509b4d34a2d62af3704 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_5.Cre_Tin_Prlv_5 +uicc.test.catre.cre_tin_prlv_5 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/javacard/cre_tin_prlv_5.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/javacard/cre_tin_prlv_5.cap new file mode 100644 index 0000000000000000000000000000000000000000..684bb37d4cd8410bfb34e1049059e46ab11e0908 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_5/javacard/cre_tin_prlv_5.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/Cre_Tin_Prlv_6.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/Cre_Tin_Prlv_6.java new file mode 100644 index 0000000000000000000000000000000000000000..b8973d94575ef631f3c88199b0d83006cf0ab9ee --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/Cre_Tin_Prlv_6.java @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_6.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_6; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_6 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_6() + { + Cre_Tin_Prlv_6.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Prlv_6 thisApplet = new Cre_Tin_Prlv_6(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 2 + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/Test_Cre_Tin_Prlv_6.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/Test_Cre_Tin_Prlv_6.java new file mode 100644 index 0000000000000000000000000000000000000000..1558d05c02ea6ba4f39bf6b1a2e7d6a1382e3365 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/Test_Cre_Tin_Prlv_6.java @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_6; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_6 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_6"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_6() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..de10e677c31fb1de5b7a42a214a976e11b4290ee --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_prlv_6.Cre_Tin_Prlv_6 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_6.Cre_Tin_Prlv_6 +uicc.test.catre.cre_tin_prlv_6 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/javacard/cre_tin_prlv_6.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/javacard/cre_tin_prlv_6.cap new file mode 100644 index 0000000000000000000000000000000000000000..0c828295eda0320cafa6e32a680534f201377b04 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_6/javacard/cre_tin_prlv_6.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/Cre_Tin_Prlv_7.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/Cre_Tin_Prlv_7.java new file mode 100644 index 0000000000000000000000000000000000000000..806972ffa60b9b4552474cd15689e36438be3ae4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/Cre_Tin_Prlv_7.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_7.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_7; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Prlv_7 extends TestToolkitApplet +{ + + private static byte bNbInstance = (byte)0 ; // instance number + private static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + private byte bMyInstanceId ; + + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_7() + { + Cre_Tin_Prlv_7.bNbInstance ++; + this.bMyInstanceId = bNbInstance; + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_7 thisApplet = new Cre_Tin_Prlv_7(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + bNbInstanceTriggered ++ ; + switch (bMyInstanceId) { + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)1: + if ( bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1 + // ----------------------------------------------------------------- + + case (byte)2: + if ( bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + break; + + default: + reportTestOutcome ((byte)1, false); + break; + + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/Test_Cre_Tin_Prlv_7.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/Test_Cre_Tin_Prlv_7.java new file mode 100644 index 0000000000000000000000000000000000000000..fdc2282149c32ab5d1c6dda2612f108c0905af5f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/Test_Cre_Tin_Prlv_7.java @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_7; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_7 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_7"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_7() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + String[] menuList = new String[3]; + String[] menuIdList = new String[3]; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..cf9edf53706889419ced75aae471549c8c325f23 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_prlv_7.Cre_Tin_Prlv_7 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_prlv_7.Cre_Tin_Prlv_7 +uicc.test.catre.cre_tin_prlv_7 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/javacard/cre_tin_prlv_7.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/javacard/cre_tin_prlv_7.cap new file mode 100644 index 0000000000000000000000000000000000000000..0d9274aa936964d24969b8c7ed253e5f750c3954 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_7/javacard/cre_tin_prlv_7.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/Cre_Tin_Prlv_8.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/Cre_Tin_Prlv_8.java new file mode 100644 index 0000000000000000000000000000000000000000..2e8ea486afcbc7ca0cb9528d94459b9a8677e911 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/Cre_Tin_Prlv_8.java @@ -0,0 +1,29 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_8.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_8; + + + +public class Cre_Tin_Prlv_8 +{ + + public static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_8() + { + + } + + +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/Test_Cre_Tin_Prlv_8.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/Test_Cre_Tin_Prlv_8.java new file mode 100644 index 0000000000000000000000000000000000000000..04b7b351296075f149b783131116a6b6a33a851b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/Test_Cre_Tin_Prlv_8.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_8; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_8 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_8"; + static final String CAP_FILE_PATH_A = "uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a"; + static final String CAP_FILE_PATH_B = "uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50110001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50110102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50210001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50210102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_8() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install packages + test.loadPackage(CAP_FILE_PATH); + test.loadPackage(CAP_FILE_PATH_A); + test.loadPackage(CAP_FILE_PATH_B); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "02" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH_B); + test.deletePackage(CAP_FILE_PATH_A); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..24e59042dbf3ad9ab85090fc149d236031b343c4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/applet.opt @@ -0,0 +1,3 @@ +-out EXP CAP JCA +uicc.test.catre.cre_tin_prlv_8 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/Cre_Tin_Prlv_8A.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/Cre_Tin_Prlv_8A.java new file mode 100644 index 0000000000000000000000000000000000000000..0b52b6ede7b26d316382bf3ac76ebda08c3ad994 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/Cre_Tin_Prlv_8A.java @@ -0,0 +1,73 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_8A.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_8.cre_tin_prlv_8a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; +import uicc.test.catre.cre_tin_prlv_8.Cre_Tin_Prlv_8 ; + + + +public class Cre_Tin_Prlv_8A extends TestToolkitApplet +{ + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_8A() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + + // Create a new applet instance + Cre_Tin_Prlv_8A thisApplet = new Cre_Tin_Prlv_8A(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + Cre_Tin_Prlv_8.bNbInstanceTriggered ++ ; + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 2 + // ----------------------------------------------------------------- + + if ( Cre_Tin_Prlv_8.bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..145d7390a326a836b5d1d95ffb179065e191f423 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x11:0x00:0x01 uicc.test.catre.cre_tin_prlv_8.cre_tin_prlv_8a.Cre_Tin_Prlv_8A +uicc.test.catre.cre_tin_prlv_8.cre_tin_prlv_8a +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x10:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/javacard/cre_tin_prlv_8a.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/javacard/cre_tin_prlv_8a.cap new file mode 100644 index 0000000000000000000000000000000000000000..80eb4bb57b36dfd157a129e11cabdc0181d44086 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8a/javacard/cre_tin_prlv_8a.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/Cre_Tin_Prlv_8B.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/Cre_Tin_Prlv_8B.java new file mode 100644 index 0000000000000000000000000000000000000000..8884d1ecc832dd41dabbe1ee35ac0c2d68dfa9ff --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/Cre_Tin_Prlv_8B.java @@ -0,0 +1,73 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_8B.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_8.cre_tin_prlv_8b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; +import uicc.test.catre.cre_tin_prlv_8.Cre_Tin_Prlv_8 ; + + + +public class Cre_Tin_Prlv_8B extends TestToolkitApplet +{ + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_8B() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_8B thisApplet = new Cre_Tin_Prlv_8B(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + Cre_Tin_Prlv_8.bNbInstanceTriggered ++ ; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1 + // ----------------------------------------------------------------- + + if ( Cre_Tin_Prlv_8.bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..13647f9bbca9dcc6980fd08023285fb545a5bff4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x21:0x00:0x01 uicc.test.catre.cre_tin_prlv_8.cre_tin_prlv_8b.Cre_Tin_Prlv_8B +uicc.test.catre.cre_tin_prlv_8.cre_tin_prlv_8b +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x20:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/javacard/cre_tin_prlv_8b.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/javacard/cre_tin_prlv_8b.cap new file mode 100644 index 0000000000000000000000000000000000000000..be53f9d9ddd8e07b6c2099a17611d9f23f8da5ef Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/cre_tin_prlv_8b/javacard/cre_tin_prlv_8b.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/javacard/cre_tin_prlv_8.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/javacard/cre_tin_prlv_8.cap new file mode 100644 index 0000000000000000000000000000000000000000..06cebe6140fc1efcc385fb7264ef6a979fe899da Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_8/javacard/cre_tin_prlv_8.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/Cre_Tin_Prlv_9.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/Cre_Tin_Prlv_9.java new file mode 100644 index 0000000000000000000000000000000000000000..1cd35cb9f40b5641a65edd813dd3aa75c60859db --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/Cre_Tin_Prlv_9.java @@ -0,0 +1,29 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_9.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_9; + + + +public class Cre_Tin_Prlv_9 +{ + + public static byte bNbInstanceTriggered = (byte)0 ; // number of times the applet is triggered + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_9() + { + + } + + +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/Test_Cre_Tin_Prlv_9.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/Test_Cre_Tin_Prlv_9.java new file mode 100644 index 0000000000000000000000000000000000000000..9570eaabf5140babbbaca936544df84a32f0d149 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/Test_Cre_Tin_Prlv_9.java @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_9; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Prlv_9 extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_prlv_9"; + static final String CAP_FILE_PATH_A = "uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a"; + static final String CAP_FILE_PATH_B = "uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50110001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50110102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50210001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50210102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Prlv_9() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + String[] menuList = new String[3]; + String[] menuIdList = new String[3]; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install packages + test.loadPackage(CAP_FILE_PATH); + test.loadPackage(CAP_FILE_PATH_A); + test.loadPackage(CAP_FILE_PATH_B); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet1 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // Install Applet2 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // Card Initialisation + test.reset(); + test.terminalProfileSession("09030020 21"); + + // Trigger the applets + response = test.envelopeEventDownloadUserActivity(); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01" + "CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH_B); + test.deletePackage(CAP_FILE_PATH_A); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d92a215a8127f9cd3fe3d9f8c4fc315712bb08cd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/applet.opt @@ -0,0 +1,3 @@ +-out EXP CAP JCA +uicc.test.catre.cre_tin_prlv_9 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/Cre_Tin_Prlv_9A.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/Cre_Tin_Prlv_9A.java new file mode 100644 index 0000000000000000000000000000000000000000..ce0f5e93af35e421a8ba9c187aa06a7196e22dec --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/Cre_Tin_Prlv_9A.java @@ -0,0 +1,72 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_9A.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_9.cre_tin_prlv_9a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; +import uicc.test.catre.cre_tin_prlv_9.Cre_Tin_Prlv_9 ; + + + +public class Cre_Tin_Prlv_9A extends TestToolkitApplet +{ + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_9A() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_9A thisApplet = new Cre_Tin_Prlv_9A(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + Cre_Tin_Prlv_9.bNbInstanceTriggered ++ ; + + // ----------------------------------------------------------------- + // Instance 1 execution, Priority Level 1, Execution in 2nd place + // ----------------------------------------------------------------- + + if ( Cre_Tin_Prlv_9.bNbInstanceTriggered == (byte)2 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d3f95f19b9669e53ee5b7fc8125072ca91d2ae80 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x11:0x00:0x01 uicc.test.catre.cre_tin_prlv_9.cre_tin_prlv_9a.Cre_Tin_Prlv_9A +uicc.test.catre.cre_tin_prlv_9.cre_tin_prlv_9a +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x10:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/javacard/cre_tin_prlv_9a.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/javacard/cre_tin_prlv_9a.cap new file mode 100644 index 0000000000000000000000000000000000000000..f240f1d14247bba2292d3ee512ec5737434069db Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9a/javacard/cre_tin_prlv_9a.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/Cre_Tin_Prlv_9B.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/Cre_Tin_Prlv_9B.java new file mode 100644 index 0000000000000000000000000000000000000000..9f254b5ee1494fa8f4467be4b8919b05331dcc4a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/Cre_Tin_Prlv_9B.java @@ -0,0 +1,72 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Prlv_9B.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_prlv_9.cre_tin_prlv_9b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; +import uicc.test.catre.cre_tin_prlv_9.Cre_Tin_Prlv_9; + + + +public class Cre_Tin_Prlv_9B extends TestToolkitApplet +{ + + /** + * Constructor of the applet + */ + public Cre_Tin_Prlv_9B() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Cre_Tin_Prlv_9B thisApplet = new Cre_Tin_Prlv_9B(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_EVENT_DOWNLOAD_USER_ACTIVITY event + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) + { + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + Cre_Tin_Prlv_9.bNbInstanceTriggered ++ ; + + // ----------------------------------------------------------------- + // Instance 2 execution, Priority Level 1, Execution in 1st place + // ----------------------------------------------------------------- + + if ( Cre_Tin_Prlv_9.bNbInstanceTriggered == (byte)1 ) { + reportTestOutcome((byte)1, true) ; + } + else { + reportTestOutcome((byte)1, false) ; + } + } + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..238d7d7f4c04b4c80e88108d6cbf2b065885b675 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x21:0x00:0x01 uicc.test.catre.cre_tin_prlv_9.cre_tin_prlv_9b.Cre_Tin_Prlv_9B +uicc.test.catre.cre_tin_prlv_9.cre_tin_prlv_9b +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x20:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/javacard/cre_tin_prlv_9b.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/javacard/cre_tin_prlv_9b.cap new file mode 100644 index 0000000000000000000000000000000000000000..df704e2ebdf2bef561928b52f2f2c3e90ab04cfc Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/cre_tin_prlv_9b/javacard/cre_tin_prlv_9b.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/javacard/cre_tin_prlv_9.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/javacard/cre_tin_prlv_9.cap new file mode 100644 index 0000000000000000000000000000000000000000..ba95fa11a441611eee1b7a69829662a23aec3233 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_prlv_9/javacard/cre_tin_prlv_9.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_1.java new file mode 100644 index 0000000000000000000000000000000000000000..eae42dd44fefe1d2cf62f368d82958b2e7af5db0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_1.java @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Sval_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_sval; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Sval_1 extends TestToolkitApplet { + + /** + * Constructor of the applet + */ + public Cre_Tin_Sval_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Sval_1 thisApplet = new Cre_Tin_Sval_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_2.java new file mode 100644 index 0000000000000000000000000000000000000000..47942a19c2d78ba8e2f9c4dad9f3cfb33578fe29 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_2.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Sval_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_sval; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Sval_2 extends TestToolkitApplet { + + // Service ID array : initially all at '0' which is not a correct service ID + public static byte[] serviceIdBuffer ; + + static byte[] menu = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'2'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Sval_2() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Sval_2 thisApplet = new Cre_Tin_Sval_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menu, (short)0, (short)menu.length, (byte)0, false, (byte) 0, (short) 0); + + // register instance with the EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent((short)EVENT_UNRECOGNIZED_ENVELOPE); + + // Allocate buffer + serviceIdBuffer = new byte[8]; + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb; + + if (event == EVENT_MENU_SELECTION) { + + // -------------------------------------------- + // Test Case 3 : Allocate 4 services + testCaseNb = (byte)0x01 ; + bRes = false ; + + try { + serviceIdBuffer[0] = obReg.allocateServiceIdentifier(); + serviceIdBuffer[1] = obReg.allocateServiceIdentifier(); + serviceIdBuffer[2] = obReg.allocateServiceIdentifier(); + serviceIdBuffer[3] = obReg.allocateServiceIdentifier(); + bRes = true ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : Allocate one more service + testCaseNb = (byte)0x02 ; + bRes = false ; + + try { + obReg.allocateServiceIdentifier(); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.NO_SERVICE_ID_AVAILABLE); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) + { + // Release referenced static buffer timerIdBuffer before deletion + serviceIdBuffer = null; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_3.java new file mode 100644 index 0000000000000000000000000000000000000000..6672cb5c36ef1ac8a1906382cc4fb50cd4d644c1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Cre_Tin_Sval_3.java @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Sval_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_sval; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Sval_3 extends TestToolkitApplet { + + //Service ID value range + short MIN_SERVICE_ID = 0; + short MAX_SERVICE_ID = 7; + + static byte[] menu = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'3'}; + public final static byte QUALIFIER_1 = (byte)0x01; + public static byte[] SERVICE_RECORD_VALUE = {(byte)0x00, (byte)0x00}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Sval_3() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Tin_Sval_3 thisApplet = new Cre_Tin_Sval_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menu, (short)0, (short)menu.length, (byte)0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb; + + short i, j; + + if (event == EVENT_MENU_SELECTION) { + // -------------------------------------------- + // Test Case 6 : Allocate 4 services + testCaseNb = (byte)0x01 ; + bRes = false ; + + try { + Cre_Tin_Sval_2.serviceIdBuffer[4] = obReg.allocateServiceIdentifier(); + Cre_Tin_Sval_2.serviceIdBuffer[5] = obReg.allocateServiceIdentifier(); + Cre_Tin_Sval_2.serviceIdBuffer[6] = obReg.allocateServiceIdentifier(); + Cre_Tin_Sval_2.serviceIdBuffer[7] = obReg.allocateServiceIdentifier(); + bRes = true ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Allocate one more service + testCaseNb = (byte)0x02 ; + bRes = false ; + + try { + obReg.allocateServiceIdentifier(); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.NO_SERVICE_ID_AVAILABLE); + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : each service id shall be between 0 and 7 and shall be different from each other + testCaseNb = (byte)0x03 ; + bRes = true ; + + for(i = 0; i < MAX_SERVICE_ID ;i++) { + + // each timerId shall be between 1 and 8 + if ((short)(Cre_Tin_Sval_2.serviceIdBuffer[i]) < MIN_SERVICE_ID || + (short)(Cre_Tin_Sval_2.serviceIdBuffer[i]) > MAX_SERVICE_ID ) { + bRes = false; + } + + // each timerId shall be different from each other + for(j = (short)(i+1); j < MAX_SERVICE_ID ;j++) { + if (Cre_Tin_Sval_2.serviceIdBuffer[i] == Cre_Tin_Sval_2.serviceIdBuffer[j] ) { + bRes = false; + } + } + + } + + reportTestOutcome(testCaseNb, bRes) ; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Test_Cre_Tin_Sval.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Test_Cre_Tin_Sval.java new file mode 100644 index 0000000000000000000000000000000000000000..d60697b30b645a0b072f11470a8fc3d60f0496d9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/Test_Cre_Tin_Sval.java @@ -0,0 +1,157 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_sval; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Sval extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_Sval"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Sval() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "09"); // V Maximum number of services + + result = response.checkSw("6A80"); + + // Select applet1 + response = test.selectApplication(APPLET_AID_1); + result &= response.getStatusWord().substring(1,3).compareTo("61") != 0; + + + /*********************************************************************/ + /** Testcase 2-4 */ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install Applet2 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "04"); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /** Testcase 5-8 */ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Install Applet3 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "08"); // V Maximum number of services + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet3 + response = test.envelopeMenuSelection("100103", ""); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "03" + "CCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // Send an unrecognized envelope to release static field in applet 2 + // before deletion. + test.unrecognizedEnvelope(); + // delete applets and package + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2ef5c9274dbe9bcfa72c1e49dcc047a9531daa09 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_sval.Cre_Tin_Sval_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_tin_sval.Cre_Tin_Sval_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_sval.Cre_Tin_Sval_1 +uicc.test.catre.cre_tin_sval +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/javacard/cre_tin_sval.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/javacard/cre_tin_sval.cap new file mode 100644 index 0000000000000000000000000000000000000000..fb34a2d97ba128c0a0f7a1bdaf5c346c64117930 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_sval/javacard/cre_tin_sval.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Cre_Tin_Tarv_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Cre_Tin_Tarv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1a67897abb64525a82410328fccc8910a88acc2e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Cre_Tin_Tarv_1.java @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Sval_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tarv; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Tarv_1 extends TestToolkitApplet { + + /** + * Constructor of the applet + */ + public Cre_Tin_Tarv_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Tarv_1 thisApplet = new Cre_Tin_Tarv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Cre_Tin_Tarv_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Cre_Tin_Tarv_2.java new file mode 100644 index 0000000000000000000000000000000000000000..b7393c5f0965949156a447cda6c87476a69cb767 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Cre_Tin_Tarv_2.java @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Sval_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tarv; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Tarv_2 extends TestToolkitApplet { + + /** + * Constructor of the applet + */ + public Cre_Tin_Tarv_2() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Tarv_2 thisApplet = new Cre_Tin_Tarv_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Test_Cre_Tin_Tarv.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Test_Cre_Tin_Tarv.java new file mode 100644 index 0000000000000000000000000000000000000000..674c0cb7ec51ea70b4fe863e7bc5b835768f3380 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/Test_Cre_Tin_Tarv.java @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tarv; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Tarv extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_tarv"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Tarv() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + // Install package + test.loadPackage(CAP_FILE_PATH); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install Applet2 with TAR "020202é + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800B" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + // LV TAR Value(s) + "03020202" + + "00"); // V Maximum number of services + + // Check correct installation + result = response.checkSw("9000"); + result = response.checkData("00"); + + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // Install Applet1 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8013" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + // LV TAR Value(s) + "09010101020202030303" + + "00"); // V Maximum number of services + + result &= response.checkSw("6A80"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Install Applet1 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800F" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + // LV TAR Value(s) + "050101010303" + + "00"); // V Maximum number of services + + result &= response.checkSw("6A80"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2a1c9a5a11af33e95b7ed6020b9420bb0337a8d7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_tarv.Cre_Tin_Tarv_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_tarv.Cre_Tin_Tarv_1 +uicc.test.catre.cre_tin_tarv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/javacard/cre_tin_tarv.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/javacard/cre_tin_tarv.cap new file mode 100644 index 0000000000000000000000000000000000000000..d0232f10447c9dc3c4410b1d48eebb3ac9300094 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tarv/javacard/cre_tin_tarv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b592b7b48277c829efd805c3d5f2b1388d93b870 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_1.java @@ -0,0 +1,46 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Tmal_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tmal ; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.test.util.* ; + + + +public class Cre_Tin_Tmal_1 extends TestToolkitApplet { + + /** + * Constructor of the applet + */ + public Cre_Tin_Tmal_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Cre_Tin_Tmal_1 thisApplet = new Cre_Tin_Tmal_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + } + + + /** + * Method called by the UIC CRE + */ + public void processToolkit(short event) { + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_2.java new file mode 100644 index 0000000000000000000000000000000000000000..8b46f8c28596b4c8f34892c8d70af7a792166eea --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_2.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// FWK_TIN_TMAL_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tmal; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + + +public class Cre_Tin_Tmal_2 extends TestToolkitApplet { + + // Timer ID array : initially all at '0' which is not a correct Timer ID + static byte[] timerIdBuffer ; + static byte[] menu = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'2'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Tmal_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + timerIdBuffer = new byte[8]; + + // Create a new applet instance + Cre_Tin_Tmal_2 thisApplet = new Cre_Tin_Tmal_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menu, (short)0, (short)menu.length, (byte)0, false, (byte) 0, (short) 0); + + // register instance with the EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent((short)EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb; + + if (event == EVENT_MENU_SELECTION) { + + // -------------------------------------------- + // Test Case 3 : Allocate 4 timers + testCaseNb = (byte)0x01 ; + bRes = false ; + + try { + timerIdBuffer[0] = obReg.allocateTimer(); + timerIdBuffer[1] = obReg.allocateTimer(); + timerIdBuffer[2] = obReg.allocateTimer(); + timerIdBuffer[3] = obReg.allocateTimer(); + bRes = true ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : Allocate one more timer + testCaseNb = (byte)0x02 ; + bRes = false ; + + try { + obReg.allocateTimer(); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.NO_TIMER_AVAILABLE); + } + reportTestOutcome(testCaseNb, bRes) ; + } + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) + { + // Release referenced static buffer timerIdBuffer before deletion + timerIdBuffer = null; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_3.java new file mode 100644 index 0000000000000000000000000000000000000000..6aef203f31275bbe5bcd54ce16d4c8e7370cc2bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Cre_Tin_Tmal_3.java @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Cre_Tin_Tmal_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tmal; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.test.util.* ; + + +public class Cre_Tin_Tmal_3 extends TestToolkitApplet { + + + //Timer ID value range + short MIN_TIMER_ID = 1; + short MAX_TIMER_ID = 8; + static byte[] menu = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'3'}; + + /** + * Constructor of the applet + */ + public Cre_Tin_Tmal_3() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Cre_Tin_Tmal_3 thisApplet = new Cre_Tin_Tmal_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menu, (short)0, (short)menu.length, (byte)0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the UICC CRE + */ + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb; + + short i, j; + + if (event == EVENT_MENU_SELECTION) { + + // -------------------------------------------- + // Test Case 6 : Allocate 4 timers + testCaseNb = (byte)0x01 ; + bRes = false ; + + try { + Cre_Tin_Tmal_2.timerIdBuffer[4] = obReg.allocateTimer(); + Cre_Tin_Tmal_2.timerIdBuffer[5] = obReg.allocateTimer(); + Cre_Tin_Tmal_2.timerIdBuffer[6] = obReg.allocateTimer(); + Cre_Tin_Tmal_2.timerIdBuffer[7] = obReg.allocateTimer(); + bRes = true ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Allocate one more timer + testCaseNb = (byte)0x02 ; + bRes = false ; + + try { + obReg.allocateTimer(); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.NO_TIMER_AVAILABLE); + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : each timerId shall be between 1 and 8 and shall be different from each other + testCaseNb = (byte)0x03 ; + bRes = true ; + + for(i = 0; i < MAX_TIMER_ID ;i++) { + + // each timerId shall be between 1 and 8 + if ((short)(Cre_Tin_Tmal_2.timerIdBuffer[i]) < MIN_TIMER_ID || + (short)(Cre_Tin_Tmal_2.timerIdBuffer[i]) > MAX_TIMER_ID ) { + bRes = false; + } + + // each timerId shall be different from each other + for(j = (short)(i+1); j < MAX_TIMER_ID ;j++) { + if (Cre_Tin_Tmal_2.timerIdBuffer[i] == Cre_Tin_Tmal_2.timerIdBuffer[j] ) { + bRes = false; + } + } + + } + + reportTestOutcome(testCaseNb, bRes) ; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Test_Cre_Tin_Tmal.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Test_Cre_Tin_Tmal.java new file mode 100644 index 0000000000000000000000000000000000000000..b363888ac267ac8cfed65be51ea3b94491c42bce --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/Test_Cre_Tin_Tmal.java @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_tin_tmal; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Tin_Tmal extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_tin_tmal"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 50030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 50030102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Tin_Tmal() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "09" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + result = response.checkSw("6A80"); + + // Select applet1 + response = test.selectApplication(APPLET_AID_1); + result &= !(response.checkData("10" + APPLET_AID_1 + "00") && response.checkSw("9000")); + + + // test script + test.reset(); + test.terminalProfileSession("09030120"); + + + /*********************************************************************/ + /** Testcase 2-4 */ + /*********************************************************************/ + + // Install Applet2 + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "04" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet2 + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /** Testcase 5-8 */ + /*********************************************************************/ + + // Install Applet3 + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "FF" + // V Priority Level + "08" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet3 + response = test.envelopeMenuSelection("100103", ""); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "02" + "CCCC"); + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "03" + "CCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // Send an unrecognized envelope to release static field in applet 2 + // before deletion. + test.unrecognizedEnvelope(); + // delete applets and package + test.deleteApplet(APPLET_AID_3); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6db6b1a3dfb0d59ea19456211c03605b61df1ad0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_tin_tmal.Cre_Tin_Tmal_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x03:0x00:0x01 uicc.test.catre.cre_tin_tmal.Cre_Tin_Tmal_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_tin_tmal.Cre_Tin_Tmal_1 +uicc.test.catre.cre_tin_tmal +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/javacard/cre_tin_tmal.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/javacard/cre_tin_tmal.cap new file mode 100644 index 0000000000000000000000000000000000000000..f2890dc365f06b060cbe2544b60ee94847f9e449 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_tin_tmal/javacard/cre_tin_tmal.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Cre_Ufa_View_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Cre_Ufa_View_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a8ed7bc02ec78fe53b1ba92d469b53eb46158eaf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Cre_Ufa_View_1.java @@ -0,0 +1,471 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_ufa_view; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.access.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * Cat Runtime Environment, UICC File Access, FileView test + * Applet1 + */ + +public class Cre_Ufa_View_1 extends TestToolkitApplet { + + private byte testCaseNb; + private boolean bRes; + static FileView classVariable; + FileView instanceVariable; + Object[] arrayComponent = new Object[1]; + byte[] readData = new byte[50]; + short offset; + byte tag; + + private FileView FileView1 = null; + private FileView FileView2 = null; + private FileView uiccFileView1 = null; + private FileView adf1FileView1 = null; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t'}; + + private byte[] adf1Aid = new byte[16]; + private UICCTestConstants uiccTestConstants; + + // Constructor of the applet + public Cre_Ufa_View_1() { + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1,(short)0,adf1Aid,(short)0,(short)adf1Aid.length); + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // create a new applet instance + Cre_Ufa_View_1 thisApplet = new Cre_Ufa_View_1(); + + // register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // initialise the data of the test applet + thisApplet.init(); + + // registration to EVENT_MENU_SELECTION and EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, (byte) 0, + false, (byte) 0, (short) 0); + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + + private short findTLV (byte tag, byte[] buffer, short offset) { + + short index=1; + short len; + + index = (short)(index + offset); + + if (buffer[(byte)index]==(byte)0x81) { + index++; + len = (short) (buffer[(byte)index] + index + (short)1); + }else if (buffer[(byte)index]==(byte)0x82){ + index = (short)(index + (short)2); + len = (short) (Util.getShort(buffer,(byte)index) + index); + } + else{ + len = (short) (buffer[(byte)index] + index + (short)1); + } + + index++; + + while (index < len) { + + if ( (buffer[(byte)index] & (byte)0x7F) == (tag & (byte)0x7F) ) { + return(index); + } + index = (short) (index + (short) buffer[(byte)(index + (byte)1)] + (short)2); + } + + return(0); + + } + + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + byte data1 ; + byte data2; + FileView localVariable; + final byte[] displayString = {(byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O'}; + + if (event == EVENT_MENU_SELECTION) { + switch (testCaseNb) { + /** test case 1: Applet can get a FileView object */ + case (byte)0x00: + testCaseNb = (byte)0x01; + try { + uiccFileView1 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + adf1FileView1 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + /** test case 2: Applet can only access all files under the MF using the UICC FileView object */ + case (byte)0x01: + testCaseNb = (byte)0x02; + try { + uiccFileView1.select(UICCTestConstants.FID_MF); + uiccFileView1.select(UICCConstants.FID_EF_DIR); + uiccFileView1.select(UICCConstants.FID_DF_TELECOM); + uiccFileView1.select(UICCTestConstants.FID_MF); + uiccFileView1.select(UICCTestConstants.FID_DF_TEST); + uiccFileView1.select(UICCTestConstants.FID_DF_SUB_TEST); + uiccFileView1.select(UICCTestConstants.FID_EF_TAA); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + try { + uiccFileView1.select((short)UICCTestConstants.FID_ADF); + bRes = false; + } + catch (Exception e) { + } + + reportTestOutcome(testCaseNb, bRes); + break; + + /** test case 3: Applet can access all files under the ADF1 using the ADF1 FileView object */ + case (byte)0x02: + testCaseNb = (byte)0x03; + bRes = false; + // 3-8 successful select() calls + try { + adf1FileView1.select((short)UICCTestConstants.FID_ADF); + adf1FileView1.select(UICCConstants.FID_DF_TELECOM); + adf1FileView1.select((short)UICCTestConstants.FID_ADF); + adf1FileView1.select(UICCTestConstants.FID_DF_TEST); + adf1FileView1.select(UICCTestConstants.FID_DF_SUB_TEST); + adf1FileView1.select(UICCTestConstants.FID_EF_TAA); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + // 9-tries to select the MF + try { + adf1FileView1.select(UICCTestConstants.FID_MF); + bRes = false; + } + catch (Exception e) { + } + + // 10-tries to select the EFDIR + try { + adf1FileView1.select(UICCConstants.FID_EF_DIR); + bRes = false; + } + catch (Exception e) { + } + + reportTestOutcome(testCaseNb, bRes); + break; + + /** test case 4: FileView object shall be provided as a permanent JCRE entry point object */ + case (byte)0x03: + testCaseNb = (byte)0x04; + bRes = false; + try { + classVariable = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + instanceVariable = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + localVariable = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + arrayComponent[0] = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + + classVariable = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + instanceVariable = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + localVariable = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + arrayComponent[0] = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + + // free static variable + classVariable = null; + + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + /** test case 5: Context independence on a FileView object */ + /** UICC FileView **/ + case (byte)0x04: + /** ADF1 FileView **/ + case (byte)0x05: + bRes = false; + // 2-get another FileView object + if (testCaseNb == 0x04) { + data1 = (byte)0x55; + data2 = (byte)0xAA; + FileView1 = uiccFileView1; + FileView2 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + } + else { + data1 = (byte)0x55;//AA; + data2 = (byte)0xAA;//55; + FileView1 = adf1FileView1; + FileView2 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + + try { + // 3-select DFTEST + FileView1.select(UICCTestConstants.FID_DF_TEST); + // select EFCARU + FileView1.select(UICCTestConstants.FID_EF_CARU); + // 4-Read record in next mode + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + bRes = true; + for (byte i = 0; i<3; i++) { + if (readData[i] == (byte)data1) { + bRes &= true; + } else { + bRes = false; + } + } + + // 5-Read record in next mode + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0xAA + for (byte i = 0; i<3; i++) { + if (readData[i] == (byte)data2) { + bRes &= true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes =false; + } + + // 6-Read record with FileView2 object in next mode (throws UICCException.NO_EF_SELECTED) + try { + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + } + catch (UICCException e) { + if (e.getReason() != UICCException.NO_EF_SELECTED) { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + // 7-select EFLARU using the FileView2 object (throws UICCException.FILE_NOT_FOUND) + try { + FileView2.select(UICCTestConstants.FID_EF_LARU); + } + catch (UICCException e) { + if (e.getReason() != UICCException.FILE_NOT_FOUND) { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + + try { + // 8-select DFTEST using the FileView2 object + FileView2.select(UICCTestConstants.FID_DF_TEST); + // select EFCARU + FileView2.select(UICCTestConstants.FID_EF_CARU); + // 9-Read record in next mode + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + for (byte i = 0; i<3; i++) { + if (readData[i] == (byte)data1) { + bRes &= true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + break; + + /** test case 6: File Context can be transient or persistent */ + /** UICC FileView **/ + case (byte)0x06: + /** ADF1 FileView **/ + case (byte)0x08: + bRes = false; + // 2-get transient/persistent FileView object + if (testCaseNb == 0x06) { + data1 = (byte)0x55; + data2 = (byte)0xAA; + FileView1 = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + FileView2 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + } + else { + data1 = (byte)0x55;//AA; + data2 = (byte)0xAA;//55; + FileView1 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.CLEAR_ON_RESET); + FileView2 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + + // 3-select DFTEST/EFCARU using FileView1 object then FileView2 object + FileView1.select(UICCTestConstants.FID_DF_TEST); + FileView1.select(UICCTestConstants.FID_EF_CARU); + FileView2.select(UICCTestConstants.FID_DF_TEST); + FileView2.select(UICCTestConstants.FID_EF_CARU); + + // 4-call the readRecord() method in the NEXT mode using FileView1 object + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + bRes = true; + for (byte i = 0; i<3; i++) { + if (readData[i] == (byte)data1) { + bRes &= true; + } else { + bRes = false; + } + } + // call the readRecord() method in the NEXT mode using FileView2 object + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + for (byte i = 0; i<3; i++) { + if (readData[i] == (byte)data1) { + bRes &= true; + } else { + bRes = false; + } + } + + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)0x07: + case (byte)0x09: + bRes = false; + if (testCaseNb == 0x07) { + data1 = (byte)0xAA; + tag = (byte) 0x83; + } else { + data1 = (byte)0xAA;//55; + tag = (byte) 0x84; + } + // 7-call the status() command using the FileView1 + FileView1.status(readData, (short)0, (short)readData.length); + // check the selected DF is MF (3F00) or ADF1 (A0 00.... only 2 first bytes are checked...) + offset = findTLV(tag, readData, (short)0); + offset+=2; + if ( (( readData[offset] == (byte)0x3F) || (readData[offset] == (byte)0xA0)) && (readData[(short)(offset+1)] == (byte)0x00) ) { + bRes = true; + } else { + bRes = false; + } + + // 8-call the status() command using the FileView2 + FileView2.status(readData, (short)0, (short)readData.length); + offset = findTLV((byte) 0x83, readData, (short)0); + offset +=2; + // check the selected DF is DETEST + if ((readData[offset] == (byte)0x7F) && (readData[(short)(offset+1)] == (byte)0x4A)) { + bRes &= true; + } else { + bRes = false; + } + // 9-call the readRecord() method in the NEXT mode using the FileView2 + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0xAA + for (byte i = 0; i<3; i++) { + if (readData[i] == (byte)data1) { + bRes &= true; + } else { + bRes = false; + } + } + // 10-call the readRecord() method in the NEXT mode using the FileView1 (throws UICCException.NO_EF_SELECTED) + try { + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + bRes = false; + } + catch (UICCException e) { + if (e.getReason() == UICCException.NO_EF_SELECTED) { + bRes &= true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + break; + + /** test case 7: File Context integrity */ + case (byte)0x0A: + bRes = false; + // 2-get a UICC FileViewFileView and select DFTEST/EFCARU + FileView1 = uiccFileView1; + FileView1.select(UICCTestConstants.FID_DF_TEST); + + // 3-send a Display Text proactive command + ProactiveHandlerSystem.getTheHandler().initDisplayText((byte)0x80, (byte)0x04, displayString, (short)0, (short)displayString.length); + ProactiveHandlerSystem.getTheHandler().send(); + + // 8-call status() command, using the same UICC FileView + FileView1.status(readData, (short)0, (short)readData.length); + // check selected DF is DF_SUB_TEST + offset = findTLV((byte)0x83, readData, (short)0); + offset+=2; + if ((readData[offset] == 0x5F) && (readData[(short)(offset+1)] == 0x10)) { + bRes = true; + } + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + break; + } + } + + // 6-select DFTEST/DF_SUB_TEST/EF_TAA, using the previous UICC FileView. + if (event == EVENT_CALL_CONTROL_BY_NAA) { + FileView1.select(UICCTestConstants.FID_DF_TEST); + FileView1.select(UICCTestConstants.FID_DF_SUB_TEST); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Cre_Ufa_View_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Cre_Ufa_View_2.java new file mode 100644 index 0000000000000000000000000000000000000000..9b5014bc350f56b16f7634b0e189f9b2d2fc72fc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Cre_Ufa_View_2.java @@ -0,0 +1,492 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_ufa_view; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +//import uicc.toolkit.*; + +import uicc.access.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * Cat Runtime Environment, UICC File Access, FileView test + * Applet2, non toolkit applet + */ + +public class Cre_Ufa_View_2 extends javacard.framework.Applet { + + private static byte triggeringNumber = 0; + private byte testCaseNb; + private boolean bRes; + private short offset; + private byte tag; + + static FileView classVariable; + FileView instanceVariable; + Object[] arrayComponent = new Object[1]; + byte[] readData = new byte[50]; + + FileView FileView1 = null; + FileView FileView2 = null; + FileView uiccFileView2 = null; + FileView adf1FileView2 = null; + + static private byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t'}; + private byte[] baTestsResults = new byte[128]; + private byte[] baTestAppletId = new byte[17]; + private byte[] adf1Aid = new byte[16]; + private UICCTestConstants uiccTestConstants; + + // Constructor of the applet + public Cre_Ufa_View_2() { + uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1,(short)0,adf1Aid,(short)0,(short)adf1Aid.length); + uiccTestConstants = null; + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // create a new applet instance + Cre_Ufa_View_2 thisApplet = new Cre_Ufa_View_2(); + + // register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // initialise the data of the test applet + thisApplet.init(); + } + + private short findTLV (byte tag, byte[] buffer, short offset) { + + short index=1; + short len; + + index = (short)(index + offset); + + if (buffer[(byte)index]==(byte)0x81) { + index++; + len = (short) (buffer[(byte)index] + index + (short)1); + }else if (buffer[(byte)index]==(byte)0x82){ + index = (short)(index + (short)2); + len = (short) (Util.getShort(buffer,(byte)index) + index); + } + else{ + len = (short) (buffer[(byte)index] + index + (short)1); + } + + index++; + + while (index < len) { + + if ( (buffer[(byte)index] & (byte)0x7F) == (tag & (byte)0x7F) ) { + return(index); + } + index = (short) (index + (short) buffer[(byte)(index + (byte)1)] + (short)2); + } + + return(0); + + } + + /** + * Method called by the JCRE, once selected + * This method allows to retrieve the detailed results of the previous execution + * may be identical for all tests + */ + public void process(APDU apdu) { + + FileView localVariable; + byte data1; + byte data2; + + if (selectingApplet()) { + switch (triggeringNumber) { + case (byte)0x00: + + /** test case 1: Applet2 can get a FileView object */ + testCaseNb = (byte)0x01; + try { + uiccFileView2 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + adf1FileView2 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + + /** test case 2: Applet2 can only access all files under the MF using the UICC FileView object */ + + testCaseNb = (byte)0x02; + try { + uiccFileView2.select(UICCTestConstants.FID_MF); + uiccFileView2.select(UICCConstants.FID_EF_DIR); + uiccFileView2.select(UICCConstants.FID_DF_TELECOM); + uiccFileView2.select(UICCTestConstants.FID_MF); + uiccFileView2.select(UICCTestConstants.FID_DF_TEST); + uiccFileView2.select(UICCTestConstants.FID_DF_SUB_TEST); + uiccFileView2.select(UICCTestConstants.FID_EF_TAA); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + try { + uiccFileView2.select(UICCTestConstants.FID_ADF); + bRes = false; + } + catch (Exception e) { + } + + reportTestOutcome(testCaseNb, bRes); + + + /** test case 3: Applet2 can access all files under the ADF1 using the ADF1 FileView object */ + testCaseNb = (byte)0x03; + bRes = false; + // 3-8 successful select() calls + try { + adf1FileView2.select((short)UICCTestConstants.FID_ADF); + adf1FileView2.select(UICCConstants.FID_DF_TELECOM); + adf1FileView2.select((short)UICCTestConstants.FID_ADF); + adf1FileView2.select(UICCTestConstants.FID_DF_TEST); + adf1FileView2.select(UICCTestConstants.FID_DF_SUB_TEST); + adf1FileView2.select(UICCTestConstants.FID_EF_TAA); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + // 9-tries to select the MF + try { + adf1FileView2.select(UICCTestConstants.FID_MF); + bRes = false; + } + catch (Exception e) { + } + + // 10-tries to select the EFDIR + try { + adf1FileView2.select(UICCConstants.FID_EF_DIR); + bRes = false; + } + catch (Exception e) { + } + + reportTestOutcome(testCaseNb, bRes); + + /** test case 4: FileView object shall be provided as a permanent JCRE entry point object */ + testCaseNb = (byte)0x04; + bRes = false; + try { + classVariable = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + instanceVariable = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + localVariable = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + arrayComponent[0] = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + + classVariable = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + instanceVariable = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + localVariable = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + arrayComponent[0] = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + + // free variables + classVariable = null; + + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** test case 5: Context independence on a FileView object */ + /** UICC FileView then ADF1 FileView **/ + for (byte i=0; i <2; i++) { + + bRes = false; + // 2-get another FileView object + if (testCaseNb == 0x04) { + data1 = (byte)0x55; + data2 = (byte)0xAA; + FileView1 = uiccFileView2; + FileView2 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + } + else { + data1 = (byte)0x55;//AA; + data2 = (byte)0xAA;//55; + FileView1 = adf1FileView2; + FileView2 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + + try { + // 3-select DFTEST + FileView1.select(UICCTestConstants.FID_DF_TEST); + // select EFCARU + FileView1.select(UICCTestConstants.FID_EF_CARU); + // 4-Read record in next mode + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + bRes = true; + for (byte j = 0; j<3; j++) { + if (readData[j] == data1) { + bRes &= true; + } else { + bRes = false; + } + } + + // 5-Read record in next mode + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0xAA + for (byte j = 0; j<3; j++) { + if (readData[j] == data2) { + bRes &= true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes =false; + } + + // 6-Read record with FileView2 object in next mode (throws UICCException.NO_EF_SELECTED) + try { + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + } + catch (UICCException e) { + if (e.getReason() != UICCException.NO_EF_SELECTED) { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + // 7-select EFLARU using the FileView2 object (throws UICCException.FILE_NOT_FOUND) + try { + FileView2.select(UICCTestConstants.FID_EF_LARU); + } + catch (UICCException e) { + if (e.getReason() != UICCException.FILE_NOT_FOUND) { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + + try { + // 8-select DFTEST using the FileView2 object + FileView2.select(UICCTestConstants.FID_DF_TEST); + // select EFCARU + FileView2.select(UICCTestConstants.FID_EF_CARU); + // 9-Read record in next mode + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + for (byte j = 0; j<3; j++) { + if (readData[j] == data1) { + bRes &= true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + } + triggeringNumber++; + break; + + /** test case 6: File Context can be transient or persistent */ + /** UICC FileView **/ + case (byte)0x01: + /** ADF1 FileView **/ + case (byte)0x03: + bRes = false; + // 2-get transient/persistent FileView object + if (testCaseNb == 0x06) { + data1 = (byte)0x55; + data2 = (byte)0xAA; + FileView1 = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + FileView2 = UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT); + } + else { + data1 = (byte)0x55;//AA; + data2 = (byte)0xAA;//55; + FileView1 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.CLEAR_ON_RESET); + FileView2 = UICCSystem.getTheFileView(adf1Aid, (short)0, (byte)adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + } + + // 3-select DFTEST/EFCARU using FileView1 object then FileView2 object + FileView1.select(UICCTestConstants.FID_DF_TEST); + FileView1.select(UICCTestConstants.FID_EF_CARU); + FileView2.select(UICCTestConstants.FID_DF_TEST); + FileView2.select(UICCTestConstants.FID_EF_CARU); + + // 4-call the readRecord() method in the NEXT mode using FileView1 object + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + for (byte j = 0; j<3; j++) { + bRes = true; + if (readData[j] == data1) { + bRes &= true; + } else { + bRes = false; + } + } + // call the readRecord() method in the NEXT mode using FileView2 object + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0x55 + for (byte j = 0; j<3; j++) { + if (readData[j] == data1) { + bRes &= true; + } else { + bRes = false; + } + } + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + triggeringNumber++; + break; + + /** a Reset is performed */ + /** UICC FileView **/ + case (byte)0x02: + /** ADF1 FileView **/ + case (byte)0x04: + + bRes = false; + if (testCaseNb == 0x07) { + data1 = (byte)0xAA; + tag = (byte) 0x83; + } else { + data1 = (byte)0xAA; + tag = (byte) 0x84; + } + // 7-call the status() command using the FileView1 + try { + FileView1.status(readData, (short)0, (short)readData.length); + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + // check the selected DF is MF (3F00) or ADF1 (A0 00.... only 2 first bytes are checked...) + offset = findTLV(tag, readData, (short)0); + offset+=2; + if (((readData[offset] == (byte)0x3F) || (readData[offset] == (byte)0xA0)) && (readData[(short)(offset+1)] == (byte)0x00) ) { + bRes &= true; + } else { + bRes = false; + } + + // 8-call the status() command using the FileView2 + FileView2.status(readData, (short)0, (short)readData.length); + // check the selected DF is DF_TEST + offset = findTLV((byte) 0x83, readData, (short)0); + offset +=2; + if ((readData[offset] == (byte)0x7F) && (readData[(short)(offset+1)] == (byte)0x4A)) { + bRes &= true; + } else { + bRes = false; + } + // 9-call the readRecord() method in the NEXT mode using the FileView2 + FileView2.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + // compare read data to 0xAA + for (byte j = 0; j<3; j++) { + if (readData[j] == data1) { + bRes &= true; + } else { + bRes = false; + } + } + // 10-call the readRecord() method in the NEXT mode using the FileView1 (throws UICCException.NO_EF_SELECTED) + try { + FileView1.readRecord((short)0, UICCConstants.REC_ACC_MODE_NEXT, (short)0, + readData, (short)0, (short)3); + bRes = false; + } + catch (UICCException e) { + if (e.getReason() == UICCException.NO_EF_SELECTED) { + bRes &= true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + + testCaseNb++; + reportTestOutcome(testCaseNb, bRes); + + /* end of th test: result is sent to the Terminal */ + if (triggeringNumber == (byte)0x04) { + + /* Construct and send the results of the tests */ + apdu.setOutgoing(); + apdu.setOutgoingLength((short)((short)(this.baTestAppletId[0] + this.baTestsResults[0]) + + (short)2)); + apdu.sendBytesLong(this.baTestAppletId, (short)0, (short)((short)(this.baTestAppletId[0]) + (short)1)); + apdu.sendBytesLong(this.baTestsResults, (short)0, (short)((short)(this.baTestsResults[0]) + (short)1)); + } + triggeringNumber++; + break; + } + } + else { + ISOException.throwIt(javacard.framework.ISO7816.SW_INS_NOT_SUPPORTED); + } + } + + /** + * Method called to initialize the AID + */ + public void init() throws SystemException { + + // Get the AID value + this.baTestAppletId[0] = JCSystem.getAID().getBytes(this.baTestAppletId, (short)1); + Util.arrayFillNonAtomic(this.baTestsResults, (short)0, (short)this.baTestsResults.length, (byte)0x00); + } + + /** + * Method called by the test applet to report the result of each test case + * + * @param testCaseNumber test case number + * @param result true if successful, false otherwise + */ + protected void reportTestOutcome(byte testCaseNumber, boolean testCaseResult) { + // Update the total number of tests executed + this.baTestsResults[0] = testCaseNumber; + + // Set the Test Case Result byte to 0xCC (for Card Compliant...) if successful + if (testCaseResult) { + this.baTestsResults[testCaseNumber] = (byte)0xCC; + } + else { + this.baTestsResults[testCaseNumber] = (byte)0x00; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Test_Cre_Ufa_View.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Test_Cre_Ufa_View.java new file mode 100644 index 0000000000000000000000000000000000000000..dd5d5117ba5e738872ef24b1a02979b0c4faf863 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/Test_Cre_Ufa_View.java @@ -0,0 +1,136 @@ +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_ufa_view; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + + +public class Test_Cre_Ufa_View extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_ufa_view"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 50020102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Ufa_View() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00"); // LV ADF1 access domain DAP + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00"); // LV ADF1 access domain DAP + + // test script + test.reset(); + test.terminalProfileSession("09010020"); + + // test case 1 to 4: trigger applet1 + test.envelopeMenuSelection("100101",""); + test.envelopeMenuSelection("100101",""); + test.envelopeMenuSelection("100101",""); + test.envelopeMenuSelection("100101",""); + + // test case 5: trigger twice applet1 + test.envelopeMenuSelection("100101",""); + test.envelopeMenuSelection("100101",""); + + // test case 6: File Context can be transient or persistent. + // Performed twice (1.with UICC FileView object 2.with ADF1 FileView object) + for (byte i=0; i<2; i++) { + test.envelopeMenuSelection("100101",""); + test.reset(); + test.terminalProfileSession("09010020"); + test.envelopeMenuSelection("100101",""); + } + + // test case 7: File Context integrity + response = test.envelopeMenuSelection("100101",""); + result = response.checkSw("9113"); + response = test.fetch("13"); + result &= response.checkSw("9000"); + + response = test.envelopeCallControlByNAA(); + result &= response.checkSw("9000"); + response = test.terminalResponse("81030121 80020282 81030100"); + result &= response.checkSw("9000"); + + // test case 8: Applet2 can get a FileView + response = test.selectApplication(APPLET_AID_2); + result = response.checkSw("9000"); + + // test cases 9 to 13 + for (byte i=0; i<2; i++) { + response = test.selectApplication(APPLET_AID_2); + result &= response.checkSw("9000"); + test.reset(); + test.terminalProfileSession("09010020"); + response = test.selectApplication(APPLET_AID_2); + } + + // check applet2 results + result &= response.checkData("10" + APPLET_AID_2 + "0ACCCCCC CCCCCCCC CCCCCC"); + + // check applet1 results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0BCCCCCC CCCCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..232926d257bfeb8bf54ada0885a9c497858f3197 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_ufa_view.Cre_Ufa_View_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_ufa_view.Cre_Ufa_View_1 +uicc.test.catre.cre_ufa_view +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/javacard/cre_ufa_view.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/javacard/cre_ufa_view.cap new file mode 100644 index 0000000000000000000000000000000000000000..a8ee394e4ce9b0fbf64be063538e0e504702fa9e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_ufa_view/javacard/cre_ufa_view.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/Test_Cre_Uta_Adel.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/Test_Cre_Uta_Adel.java new file mode 100644 index 0000000000000000000000000000000000000000..397bb423b074f8eb65d5b7a12feb57bdccf66561 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/Test_Cre_Uta_Adel.java @@ -0,0 +1,436 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_adel; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Uta_Adel extends UiccTestModel { + + static final String CAP_FILE_PATH_A = "uicc/test/catre/cre_uta_adel/cre_uta_adel_a"; + static final String CLASS_AID_A_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_A_1 = "A0000000 090005FF FFFFFF89 50010102"; + + static final String CLASS_AID_A_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_A_2 = "A0000000 090005FF FFFFFF89 50020102"; + + + static final String CAP_FILE_PATH_B = "uicc/test/catre/cre_uta_adel/cre_uta_adel_b"; + static final String CLASS_AID_B_1 = "A0000000 090005FF FFFFFF89 50110001"; + static final String APPLET_AID_B_1 = "A0000000 090005FF FFFFFF89 50110102"; + + static final String CLASS_AID_B_2 = "A0000000 090005FF FFFFFF89 50120001"; + static final String APPLET_AID_B_2 = "A0000000 090005FF FFFFFF89 50120102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Uta_Adel() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install packageA + test.loadPackage(CAP_FILE_PATH_A); + // Install packageB + test.loadPackage(CAP_FILE_PATH_B); + + + + // Install AppletA1 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Install AppletA2 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_2, APPLET_AID_A_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Id of menu entry 1 + "02" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + // Install AppletB1 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_1, APPLET_AID_B_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + // Install AppletB2 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_2, APPLET_AID_B_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "04" + // V Id of menu entry 1 + "04" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + // The deletion shall fail if any object owned by the applet instance + // is referenced from an object owned by another applet instance on the card + + + // 1- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 3- Trigger AppletA2 + test.envelopeMenuSelection("100102", ""); + + // 5- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result = !response.checkSw("9000"); //response shall be different from 90 00 + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 6- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 7- Trigger AppletA2 + response = test.envelopeMenuSelection("100102", ""); + result &= response.checkSw("9000"); + + // 9- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= response.checkSw("9000"); + + // 10- Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 11- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 13- Trigger AppletB2 + test.envelopeMenuSelection("100104", ""); + + // 15- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 16- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 17- Trigger AppletB2 + response = test.envelopeMenuSelection("100104", ""); + result &= response.checkSw("9000"); + + // 19- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= response.checkSw("9000"); + + // 20- Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + // The deletion shall failed if any object owned by the applet instance + // is referenced from a static field on any package on the card + + + // 1- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 3- Trigger AppletA2 + test.envelopeMenuSelection("100102", ""); + + // 5- Delete AppletA2 + response = test.deleteApplet(APPLET_AID_A_2); + result &= response.checkSw("9000"); + + // 6- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 7- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 9- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= response.checkSw("9000"); + + // 10- Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 11- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 13- Trigger AppletB2 + test.envelopeMenuSelection("100104", ""); + + // 15- Delete AppletB2 + response = test.deleteApplet(APPLET_AID_B_2); + result &= response.checkSw("9000"); + + // 16- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 17- Trigger AppletA1 + test.envelopeMenuSelection("100101", ""); + + // 18- Trigger AppletB1 + test.envelopeMenuSelection("100103", ""); + + //check data + response = test.selectApplication(APPLET_AID_A_1); + result &= response.checkData("10" + APPLET_AID_A_1 + + "08CCCCCC CCCCCCCC CC"); + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 20- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= response.checkSw("9000"); + + // 21- Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + // Deletion of an active applet instance + + // 1- Delete AppletB1 + response = test.deleteApplet(APPLET_AID_B_1); + result &= response.checkSw("9000"); + + // 2- Install AppletB1 + response = test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_1, APPLET_AID_B_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 3- Select AppletB1 on a different channel + response = test.manageChannel("00", "00");//Open channel if P1=00 P2 is reserved + response = test.selectApplication(response.getData(), APPLET_AID_B_1); + result &= response.checkData("10" + APPLET_AID_B_1 + + "00"); + result &= response.checkSw("9000"); + + // 4- Delete AppletB1 + response = test.deleteApplet(APPLET_AID_B_1); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + + // 5- Select AppletB1 + response = test.selectApplication(APPLET_AID_B_1); + result &= response.checkData("10" + APPLET_AID_B_1 + + "00"); + result &= response.checkSw("9000"); + + // 6- reset + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + // Selection of a deleted applet instance + + + + // 1- Delete AppletB1 + response = test.deleteApplet(APPLET_AID_B_1); + result &= response.checkSw("9000"); + + // 2- Select AppletB1 + response = test.selectApplication(APPLET_AID_B_1); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + // 3- Install AppletB1 + response = test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_1, APPLET_AID_B_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "03" + // V Id of menu entry 1 + "03" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + // Object owned by a deleted applet can’t be accessed by other applets + + + // 1- Delete AppletA1 + response = test.deleteApplet(APPLET_AID_A_1); + result &= response.checkSw("9000"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 2- Trigger AppletB1 + test.envelopeMenuSelection("100103", ""); + + response = test.selectApplication(APPLET_AID_B_1); + result &= response.checkData("10" + APPLET_AID_B_1 + + "01CC"); + + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete AppletB1 + test.deleteApplet(APPLET_AID_B_1); + + test.deletePackage(CAP_FILE_PATH_B); + test.deletePackage(CAP_FILE_PATH_A); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d102bbfd54f1232c85da59e17069545a22e38875 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_1.java @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Adel_A_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_adel.cre_uta_adel_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +//server applet +public class Cre_Uta_Adel_A_1 extends TestToolkitApplet implements Cre_Uta_Adel_A_3 { + + + static byte[] menuA1 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'A', (byte)'1'}; + + static byte menuIdentifier; + + static byte[] appletAidA2 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x02, (byte)0x01, (byte)0x02}; + + static byte[] appletAidB1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x11, (byte)0x01, (byte)0x02}; + + static byte[] appletAidB2 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x12, (byte)0x01, (byte)0x02}; + + + //as the applet is installed and deleted several times an auxiliar static array is used + //to check the applet is triggered + static byte staticBTestCaseNbA1 = (byte)0x01; + static boolean[] staticArrayTestCaseNbA1 = {(boolean) false,(boolean) false,(boolean) false,(boolean) false, + (boolean) false,(boolean) false,(boolean) false,(boolean) false}; + + + + /** + * Constructor of the applet + */ + public Cre_Uta_Adel_A_1() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Adel_A_1 thisApplet = new Cre_Uta_Adel_A_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuA1, (short)0, (short)menuA1.length, (byte)0, false, (byte) 0, (short) 0); + + } + + public byte getMenuId() { + + return(menuIdentifier); + + } + + public Shareable getShareableInterfaceObject(AID clientAID, byte parameter) { + + if ((clientAID == null) && (parameter == (byte)0x01)) { + return((Shareable) this); + } else { + if((clientAID.equals(appletAidA2, (short)0, (byte) appletAidA2.length) == true) + ||(clientAID.equals(appletAidB1, (short)0, (byte) appletAidB1.length) == true) + ||(clientAID.equals(appletAidB2, (short)0, (byte) appletAidB2.length) == true)) { + return((Shareable) this); + } else { + return(null); + } + } + } + + public void processToolkit(short event) { + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + boolean bRes = false; + + if (event == EVENT_MENU_SELECTION) { + + if (staticBTestCaseNbA1 == 0x06) { + //It is the sixth trigger + Cre_Uta_Adel_A_2.shareInterfaceStatic = null; + + } else { + //staticBTestCaseNbA1 -> 1,2,3,4,5,7,8 + menuIdentifier = envHdlr.getItemIdentifier(); + } + + bRes = true; + } + staticArrayTestCaseNbA1[staticBTestCaseNbA1-1] = bRes; + if(staticBTestCaseNbA1 == 0x08){ + + for (byte i=0; i<8; i++){ + reportTestOutcome((byte) (i+1), staticArrayTestCaseNbA1[i]); + } + } + staticBTestCaseNbA1++; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_2.java new file mode 100644 index 0000000000000000000000000000000000000000..cda7f8c7a01d220f9ee27cea15474cc10a58d1f1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_2.java @@ -0,0 +1,96 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Adel_A_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_adel.cre_uta_adel_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Adel_A_2 extends TestToolkitApplet{ + + static byte[] menuA2 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'A', (byte)'2'}; + + static byte[] appletAidA1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x01, (byte)0x01, (byte)0x02}; + + AID serverAid; + + byte bTestCaseNbA2 = (byte)0x01; + + Cre_Uta_Adel_A_3 shareInterface; + + static Cre_Uta_Adel_A_3 shareInterfaceStatic; + + /** + * Constructor of the applet + */ + public Cre_Uta_Adel_A_2(){ + + serverAid = new AID(appletAidA1, (short) 0, (byte) appletAidA1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Adel_A_2 thisApplet = new Cre_Uta_Adel_A_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.initMenuEntry(menuA2, (short)0, (short)menuA2.length, (byte)0, false, (byte) 0, (short) 0); + + } + + + public void processToolkit(short event) { + + byte menuIdA1 = (byte)0; + + if (event == EVENT_MENU_SELECTION) { + + + switch(bTestCaseNbA2){ + + case 0x01: + shareInterface = (Cre_Uta_Adel_A_3) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + menuIdA1 = shareInterface.getMenuId(); + break; + + case 0x02: + shareInterface = null; + break; + + case 0x03: + shareInterfaceStatic = (Cre_Uta_Adel_A_3) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + menuIdA1 = shareInterfaceStatic.getMenuId(); + break; + + } + bTestCaseNbA2++; + } + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_3.java new file mode 100644 index 0000000000000000000000000000000000000000..ed024f3625bf596d938dd0014e7a90a468c87948 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/Cre_Uta_Adel_A_3.java @@ -0,0 +1,24 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Adel_A_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_adel.cre_uta_adel_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + +public interface Cre_Uta_Adel_A_3 extends Shareable{ + + + public byte getMenuId(); + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2f858839c23e83b186205ce2319f41ad989cab45 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_uta_adel.cre_uta_adel_a.Cre_Uta_Adel_A_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_uta_adel.cre_uta_adel_a.Cre_Uta_Adel_A_1 +uicc.test.catre.cre_uta_adel.cre_uta_adel_a +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/javacard/cre_uta_adel_a.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/javacard/cre_uta_adel_a.cap new file mode 100644 index 0000000000000000000000000000000000000000..12c512d977285f37d0b9c02bb4bd4ddeda1d74da Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_a/javacard/cre_uta_adel_a.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/Cre_Uta_Adel_B_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/Cre_Uta_Adel_B_1.java new file mode 100644 index 0000000000000000000000000000000000000000..aed2897cb9cb1403572ec4c925fb49f1964bac20 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/Cre_Uta_Adel_B_1.java @@ -0,0 +1,113 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Adel_B_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_adel.cre_uta_adel_b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; +import uicc.test.catre.cre_uta_adel.cre_uta_adel_a.*; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Adel_B_1 extends TestToolkitApplet implements MultiSelectable +{ + + + static byte[] menuB1 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'B', (byte)'1'}; + + Cre_Uta_Adel_A_3 shareInterfaceB1; + + static byte[] appletAidA1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x01, (byte)0x01, (byte)0x02}; + + AID serverAid; + + static byte bTestCaseNbB1 = (byte)0x01; + + + /** + * Constructor of the applet + */ + public Cre_Uta_Adel_B_1(){ + + serverAid = new AID(appletAidA1, (short) 0, (byte) appletAidA1.length); + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Adel_B_1 thisApplet = new Cre_Uta_Adel_B_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuB1, (short)0, (short)menuB1.length, (byte)0, false, (byte) 0, (short) 0); + + } + + + public void processToolkit(short event){ + + boolean bRes = false; + + if (event == EVENT_MENU_SELECTION) { + + switch(bTestCaseNbB1){ + + case 0x01: + + Cre_Uta_Adel_B_2.shareInterfaceStatic = null; + bTestCaseNbB1++; + break; + + case 0x02: + + //second trigger + try{ + shareInterfaceB1 = (Cre_Uta_Adel_A_3) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + bRes = (shareInterfaceB1 == null); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 1, bRes); + break; + } + } + } + + /* (non-Javadoc) + * @see javacard.framework.MultiSelectable#select(boolean) + */ + public boolean select(boolean arg0) { + return true; + } + + /* (non-Javadoc) + * @see javacard.framework.MultiSelectable#deselect(boolean) + */ + public void deselect(boolean arg0) { + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/Cre_Uta_Adel_B_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/Cre_Uta_Adel_B_2.java new file mode 100644 index 0000000000000000000000000000000000000000..c3e1b4e99249ca77f2b12b86aa2f75340a8797d0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/Cre_Uta_Adel_B_2.java @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Adel_B_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_adel.cre_uta_adel_b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; +import uicc.test.catre.cre_uta_adel.cre_uta_adel_a.*; + + + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Adel_B_2 extends TestToolkitApplet implements MultiSelectable{ + + static byte[] menuB2 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'B', (byte)'2'}; + + static byte[] appletAidA1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x01, (byte)0x01, (byte)0x02}; + + AID serverAid; + + byte bTestCaseNbB2 = (byte)0x01; + + Cre_Uta_Adel_A_3 shareInterfaceB2; + + static Cre_Uta_Adel_A_3 shareInterfaceStatic; + + + /** + * Constructor of the applet + */ + public Cre_Uta_Adel_B_2() { + + serverAid = new AID(appletAidA1, (short) 0, (byte) appletAidA1.length); + + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength){ + // Create a new applet instance. + Cre_Uta_Adel_B_2 thisApplet = new Cre_Uta_Adel_B_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuB2, (short)0, (short)menuB2.length, (byte)0, false, (byte) 0, (short) 0); + + + } + + + public void processToolkit(short event) { + + byte menuIdA1 = (byte)0; + + if (event == EVENT_MENU_SELECTION) { + + switch(bTestCaseNbB2){ + + case 0x01: + shareInterfaceB2 = (Cre_Uta_Adel_A_3) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + menuIdA1 = shareInterfaceB2.getMenuId(); + break; + + case 0x02: + shareInterfaceB2 = null; + break; + + case 0x03: + shareInterfaceStatic = (Cre_Uta_Adel_A_3) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + menuIdA1 = shareInterfaceStatic.getMenuId(); + break; + } + bTestCaseNbB2++; + } + } + + /* (non-Javadoc) + * @see javacard.framework.MultiSelectable#select(boolean) + */ + public boolean select(boolean arg0) { + return true; + } + + /* (non-Javadoc) + * @see javacard.framework.MultiSelectable#deselect(boolean) + */ + public void deselect(boolean arg0) { + } + + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..f5cf408af1bf131be208e1be6ee29aa9698c782c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x12:0x00:0x01 uicc.test.catre.cre_uta_adel.cre_uta_adel_b.Cre_Uta_Adel_B_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x11:0x00:0x01 uicc.test.catre.cre_uta_adel.cre_uta_adel_b.Cre_Uta_Adel_B_1 +uicc.test.catre.cre_uta_adel.cre_uta_adel_b +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x10:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/javacard/cre_uta_adel_b.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/javacard/cre_uta_adel_b.cap new file mode 100644 index 0000000000000000000000000000000000000000..251361f8c4bb2f35ef61ca28663763811a0b6271 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_adel/cre_uta_adel_b/javacard/cre_uta_adel_b.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/Test_Cre_Uta_Dafs.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/Test_Cre_Uta_Dafs.java new file mode 100644 index 0000000000000000000000000000000000000000..a9abc6509d6804097b013d826c664778ac74b0ff --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/Test_Cre_Uta_Dafs.java @@ -0,0 +1,119 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_dafs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Uta_Dafs extends UiccTestModel { + + static final String CAP_FILE_PATH_A = "uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a"; + static final String CLASS_AID_A_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_A_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + static final String CAP_FILE_PATH_B = "uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b"; + static final String CLASS_AID_B_1 = "A0000000 090005FF FFFFFF89 50110001"; + static final String APPLET_AID_B_1 = "A0000000 090005FF FFFFFF89 50110102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Uta_Dafs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package A + test.loadPackage(CAP_FILE_PATH_A); + // Install package B + test.loadPackage(CAP_FILE_PATH_B); + + // Install Applet A1 + test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Position of menu entry 1 + "01" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + // Install Applet B1 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_1, APPLET_AID_B_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Position of menu entry 1 + "02" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09010020"); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + + + // 1- Trigger Applet1 2- AppletA1 stores the menu Id + test.envelopeMenuSelection("100101", ""); + + // 3- Send an envelope Menu Selection to trigger AppletB1 + // 4- AppletB1 uses the shareable interface of AppletA1 to retrieve the Menu Id that was + // used to trigger AppletA1 previously + test.envelopeMenuSelection("100102", ""); + + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_B_1); + result = response.checkData("10" + APPLET_AID_B_1 + + "01CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete AppletA1 and AppletB1 + test.deleteApplet(APPLET_AID_B_1); + test.deleteApplet(APPLET_AID_A_1); + test.deletePackage(CAP_FILE_PATH_B); + test.deletePackage(CAP_FILE_PATH_A); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6d8e5a11a9ecef90016479aa59892bd9c89435cc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_1.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Dafs_A_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_dafs.cre_uta_dafs_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +//server applet +public class Cre_Uta_Dafs_A_1 extends TestToolkitApplet{ + + + static byte[] menuA1 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'A', (byte)'1'}; + + Cre_Uta_Dafs_A_3 shareClass; + + static byte menuIdentifier; + + static byte[] appletAidB1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x11, (byte)0x01, (byte)0x02}; + + + + /** + * Constructor of the applet + */ + public Cre_Uta_Dafs_A_1(){ + + shareClass = new Cre_Uta_Dafs_A_3(); + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Dafs_A_1 thisApplet = new Cre_Uta_Dafs_A_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuA1, (short)0, (short)menuA1.length, (byte)0, false, (byte) 0, (short) 0); + + } + + + public void processToolkit(short event){ + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + if (event == EVENT_MENU_SELECTION) { + + menuIdentifier = envHdlr.getItemIdentifier(); + + } + + } + + public Shareable getShareableInterfaceObject(AID clientAID, byte parameter) { + + if ((clientAID == null) && (parameter == (byte)0x01)) { + return((Shareable) this); + }else{ + if(clientAID.equals(appletAidB1, (short)0, (byte) appletAidB1.length) == true) { + return((Shareable) shareClass); + }else { + return(null); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_2.java new file mode 100644 index 0000000000000000000000000000000000000000..ff294647230990aa59a697a0ae4175df2174de4e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_2.java @@ -0,0 +1,31 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Dafs_A_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_dafs.cre_uta_dafs_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public interface Cre_Uta_Dafs_A_2 extends Shareable{ + + + public byte getMenuId(); + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_3.java new file mode 100644 index 0000000000000000000000000000000000000000..a66bfcdc7220309fc0db2f5c883fdf884c697170 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/Cre_Uta_Dafs_A_3.java @@ -0,0 +1,28 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Dafs_A_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_dafs.cre_uta_dafs_a; + + + +public class Cre_Uta_Dafs_A_3 implements Cre_Uta_Dafs_A_2 { + + /** + * Constructor of the class + */ + public Cre_Uta_Dafs_A_3() { + } + + + public byte getMenuId() { + + return(Cre_Uta_Dafs_A_1.menuIdentifier); + + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..f3eb6288f801cdfdcca391a9c141e3128dcb8634 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_uta_dafs.cre_uta_dafs_a.Cre_Uta_Dafs_A_1 +uicc.test.catre.cre_uta_dafs.cre_uta_dafs_a +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/javacard/cre_uta_dafs_a.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/javacard/cre_uta_dafs_a.cap new file mode 100644 index 0000000000000000000000000000000000000000..e174e8e8ef16251fcda9d3973e99145489dbd211 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_a/javacard/cre_uta_dafs_a.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/Cre_Uta_Dafs_B_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/Cre_Uta_Dafs_B_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5f7d7e4f57cc73b69b00646c2c871b8d5a39f951 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/Cre_Uta_Dafs_B_1.java @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Dafs_B_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_dafs.cre_uta_dafs_b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; +import uicc.test.catre.cre_uta_dafs.cre_uta_dafs_a.*; + + + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Dafs_B_1 extends TestToolkitApplet{ + + static byte[] menuB1 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'B', (byte)'1'}; + + static byte[] appletAidA1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x01, (byte)0x01, (byte)0x02}; + + AID serverAid; + + Cre_Uta_Dafs_A_2 shareInterface; + + /** + * Constructor of the applet + */ + public Cre_Uta_Dafs_B_1() { + + serverAid = new AID(appletAidA1, (short) 0, (byte) appletAidA1.length); + + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength){ + // Create a new applet instance. + Cre_Uta_Dafs_B_1 thisApplet = new Cre_Uta_Dafs_B_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuB1, (short)0, (short)menuB1.length, (byte)0, false, (byte) 0, (short) 0); + + + } + + + public void processToolkit(short event) { + + boolean bRes = false; + byte bTestCaseNb = (byte)1; + byte menuIdA1 = (byte)0; + + if (event == EVENT_MENU_SELECTION) { + + shareInterface = (Cre_Uta_Dafs_A_2) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + menuIdA1 = shareInterface.getMenuId(); + + if (menuIdA1 == 0x01){ + bRes = true; + } + reportTestOutcome(bTestCaseNb, bRes); + + } + + } + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a813c6b6105ab66e3f750c19966a200ea486ca92 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x11:0x00:0x01 uicc.test.catre.cre_uta_dafs.cre_uta_dafs_b.Cre_Uta_Dafs_B_1 +uicc.test.catre.cre_uta_dafs.cre_uta_dafs_b +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x10:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/javacard/cre_uta_dafs_b.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/javacard/cre_uta_dafs_b.cap new file mode 100644 index 0000000000000000000000000000000000000000..3083c339ab1a192642cef722b2b45076422160a8 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_dafs/cre_uta_dafs_b/javacard/cre_uta_dafs_b.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/Cre_Uta_Odel_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/Cre_Uta_Odel_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ff0b662a9a8df6af986f574c7572958208703868 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/Cre_Uta_Odel_1.java @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Odel_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_odel; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Odel_1 extends TestToolkitApplet{ + + /** + * Constructor of the applet + */ + public Cre_Uta_Odel_1(){ + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + + + // Create a new applet instance. + Cre_Uta_Odel_1 thisApplet = new Cre_Uta_Odel_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + thisApplet.obReg.setEvent(EVENT_PROFILE_DOWNLOAD); + + + + } + + + public void processToolkit(short event){ + + boolean bRes = false; + byte bTestCaseNb = (byte)1; + + if (JCSystem.isObjectDeletionSupported()){ + bRes =true; + } + reportTestOutcome(bTestCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/Test_Cre_Uta_Odel.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/Test_Cre_Uta_Odel.java new file mode 100644 index 0000000000000000000000000000000000000000..ffec940f7b649bf7763fdf31c1d0acb747cfff39 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/Test_Cre_Uta_Odel.java @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_odel; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Uta_Odel extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/catre/cre_uta_odel"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 50010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Uta_Odel() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // Install package + test.loadPackage(CAP_FILE_PATH); + + // Install Applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + //Object deletion is supported + test.reset(); + test.terminalProfile("0101"); + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "01CC"); + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + // delete Applet and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..42703215170bd32e0a2fdc1ec646b977d9e9ebe6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_uta_odel.Cre_Uta_Odel_1 +uicc.test.catre.cre_uta_odel +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/javacard/cre_uta_odel.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/javacard/cre_uta_odel.cap new file mode 100644 index 0000000000000000000000000000000000000000..db97e5370a9f8458033f478c4116c304eea21119 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_odel/javacard/cre_uta_odel.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/Test_Cre_Uta_Pdel.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/Test_Cre_Uta_Pdel.java new file mode 100644 index 0000000000000000000000000000000000000000..a41bdcfe04bfe3d442960b0a49f67be3d76b65bf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/Test_Cre_Uta_Pdel.java @@ -0,0 +1,217 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_pdel; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Cre_Uta_Pdel extends UiccTestModel { + + static final String CAP_FILE_PATH_A = "uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a"; + static final String CLASS_AID_A_1 = "A0000000 090005FF FFFFFF89 50010001"; + static final String APPLET_AID_A_1 = "A0000000 090005FF FFFFFF89 50010102"; + + static final String CLASS_AID_A_2 = "A0000000 090005FF FFFFFF89 50020001"; + static final String APPLET_AID_A_2 = "A0000000 090005FF FFFFFF89 50020102"; + + + static final String CAP_FILE_PATH_B = "uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b"; + static final String CLASS_AID_B_1 = "A0000000 090005FF FFFFFF89 50110001"; + static final String APPLET_AID_B_1 = "A0000000 090005FF FFFFFF89 50110102"; + + static final String CLASS_AID_B_2 = "A0000000 090005FF FFFFFF89 50120001"; + static final String APPLET_AID_B_2 = "A0000000 090005FF FFFFFF89 50120102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Cre_Uta_Pdel() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install packageA + test.loadPackage(CAP_FILE_PATH_A); + // Install packageB + test.loadPackage(CAP_FILE_PATH_B); + + // Install AppletB1 + test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_1, APPLET_AID_B_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "02" + // V Position of menu entry 1 + "02" + // V Id of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + // The package deletion is unsuccessful if a reachable instance + // of a class belonging to the package exists on the card + + + // Delete PackageB + response = test.deletePackage(CAP_FILE_PATH_B); + result = !response.checkSw("9000"); //response shall be different from 90 00 + + + // Install AppletB2 + response = test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_2, APPLET_AID_B_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + // Delete AppletB1 and AppletB2 + test.deleteApplet(APPLET_AID_B_1); + test.deleteApplet(APPLET_AID_B_2); + + + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + // The package deletion is unsuccessful if another package on the card depends on this package + + + // Delete PackageA + response = test.deletePackage(CAP_FILE_PATH_A); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + // Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + result &= response.checkData("00"); + result &= response.checkSw("9000"); + // Delete AppletA1 + test.deleteApplet(APPLET_AID_A_1); + + + + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + // The installation of a package which depends on a deleted package shall fail + + + // Delete PackageB + response = test.deletePackage(CAP_FILE_PATH_B); + result &= response.checkSw("9000"); + + // Delete PackageA + response = test.deletePackage(CAP_FILE_PATH_A); + result &= response.checkSw("9000"); + + // Install packageB + response = test.loadPackage(CAP_FILE_PATH_B); + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + //Once a package is deleted, it shall not be possible to install an applet from this package + + + // Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + // Install AppletB2 + response = test.installApplet(CAP_FILE_PATH_B, CLASS_AID_B_2, APPLET_AID_B_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + result &= !response.checkSw("9000"); //response shall be different from 90 00 + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + //This test checks that it is possible to re-install the same package + + // Install packageA + test.loadPackage(CAP_FILE_PATH_A); + + // Install AppletA1 + response = test.installApplet(CAP_FILE_PATH_A, CLASS_AID_A_1, APPLET_AID_A_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + result &= response.checkData("00"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete AppletA1 and packageA + test.deleteApplet(APPLET_AID_A_1); + test.deletePackage(CAP_FILE_PATH_A); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_1.java new file mode 100644 index 0000000000000000000000000000000000000000..59c8229649cd0fad7ff7034367e7e259a2944cc1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_1.java @@ -0,0 +1,52 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Pdel_A_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Pdel_A_1 extends TestToolkitApplet{ + + /** + * Constructor of the applet + */ + public Cre_Uta_Pdel_A_1(){ + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Pdel_A_1 thisApplet = new Cre_Uta_Pdel_A_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + } + + + public void processToolkit(short event){ + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_2.java new file mode 100644 index 0000000000000000000000000000000000000000..308a73ed506286cfcf15fd9cdba9b0a3c803b1dc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_2.java @@ -0,0 +1,93 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Pdel_A_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +//server applet +public class Cre_Uta_Pdel_A_2 extends TestToolkitApplet{ + + + static byte[] menuA2 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'A', (byte)'2'}; + + static byte menuIdentifier; + + static byte[] appletAidB1 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x11, (byte)0x01, (byte)0x02}; + + + + /** + * Constructor of the applet + */ + public Cre_Uta_Pdel_A_2() { + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Pdel_A_2 thisApplet = new Cre_Uta_Pdel_A_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuA2, (short)0, (short)menuA2.length, (byte)0, false, (byte) 0, (short) 0); + + } + + public byte getMenuId() { + + return(menuIdentifier); + + } + public void processToolkit(short event) { + + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + if (event == EVENT_MENU_SELECTION) { + + menuIdentifier = envHdlr.getItemIdentifier(); + + } + + } + + public Shareable getShareableInterfaceObject(AID clientAID, byte parameter) { + + if ((clientAID == null) && (parameter == (byte)0x01)) { + return((Shareable) this); + } else { + if(clientAID.equals(appletAidB1, (short)0, (byte) appletAidB1.length) == true) { + return((Shareable) this); + } else { + return(null); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_3.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_3.java new file mode 100644 index 0000000000000000000000000000000000000000..ad7767fa1e67bb9d537fbfdd5c823b12666e1408 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/Cre_Uta_Pdel_A_3.java @@ -0,0 +1,24 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Pdel_A_3.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + + +public interface Cre_Uta_Pdel_A_3 extends Shareable{ + + + public byte getMenuId(); + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ec8378641f93340a78be5cf91a030ef9de939647 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x02:0x00:0x01 uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a.Cre_Uta_Pdel_A_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x01:0x00:0x01 uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a.Cre_Uta_Pdel_A_1 +uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/javacard/cre_uta_pdel_a.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/javacard/cre_uta_pdel_a.cap new file mode 100644 index 0000000000000000000000000000000000000000..3c0035dc7c23870d2082236f8243fd19431a853c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_a/javacard/cre_uta_pdel_a.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/Cre_Uta_Pdel_B_1.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/Cre_Uta_Pdel_B_1.java new file mode 100644 index 0000000000000000000000000000000000000000..90cc362483cd27e419b32e765b1aa94456ab1a3c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/Cre_Uta_Pdel_B_1.java @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Pdel_B_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_pdel.cre_uta_pdel_b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; +import uicc.test.catre.cre_uta_pdel.cre_uta_pdel_a.*; + + + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Pdel_B_1 extends TestToolkitApplet{ + + static byte[] menuB1 = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', (byte)'e', (byte)'t', (byte)'B', (byte)'1'}; + + static byte[] appletAidA2 = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, (byte)0x50, (byte)0x01, (byte)0x01, (byte)0x02}; + + AID serverAid; + + Cre_Uta_Pdel_A_3 shareInterface; + + /** + * Constructor of the applet + */ + public Cre_Uta_Pdel_B_1() { + + serverAid = new AID(appletAidA2, (short) 0, (byte) appletAidA2.length); + + + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength){ + // Create a new applet instance. + Cre_Uta_Pdel_B_1 thisApplet = new Cre_Uta_Pdel_B_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // register instance with the EVENT_MENU_SELECTION event + thisApplet.obReg.initMenuEntry(menuB1, (short)0, (short)menuB1.length, (byte)0, false, (byte) 0, (short) 0); + + + } + + + public void processToolkit(short event) { + + boolean bRes = false; + byte bTestCaseNb = (byte)1; + byte menuIdA2 = (byte)0; + + if (event == EVENT_MENU_SELECTION) { + + shareInterface = (Cre_Uta_Pdel_A_3) JCSystem.getAppletShareableInterfaceObject(serverAid,(byte) 0); + menuIdA2 = shareInterface.getMenuId(); + + if (menuIdA2 == 0x01){ + bRes = true; + } + reportTestOutcome(bTestCaseNb, bRes); + + } + + } + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/Cre_Uta_Pdel_B_2.java b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/Cre_Uta_Pdel_B_2.java new file mode 100644 index 0000000000000000000000000000000000000000..d90d66a7bc581e644207d3b44cdfb310c7dc4d4e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/Cre_Uta_Pdel_B_2.java @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------------- +// Cre_Uta_Pdel_B_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.catre.cre_uta_pdel.cre_uta_pdel_b; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.toolkit.* ; +import uicc.test.util.* ; + +/** + * Test Area : uicc.catre... + * + * Applet is triggered on Install (Install) + * + * + */ + +public class Cre_Uta_Pdel_B_2 extends TestToolkitApplet +{ + + /** + * Constructor of the applet + */ + public Cre_Uta_Pdel_B_2(){ + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Cre_Uta_Pdel_B_2 thisApplet = new Cre_Uta_Pdel_B_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + + } + + + public void processToolkit(short event){ + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/applet.opt b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2592c33143b90ec6f7c08608e13dda6307e0b062 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x12:0x00:0x01 uicc.test.catre.cre_uta_pdel.cre_uta_pdel_b.Cre_Uta_Pdel_B_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x11:0x00:0x01 uicc.test.catre.cre_uta_pdel.cre_uta_pdel_b.Cre_Uta_Pdel_B_1 +uicc.test.catre.cre_uta_pdel.cre_uta_pdel_b +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x50:0x10:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/javacard/cre_uta_pdel_b.cap b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/javacard/cre_uta_pdel_b.cap new file mode 100644 index 0000000000000000000000000000000000000000..248a6d0e9695a0246faa4e718fac8d284b39bed3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/catre/cre_uta_pdel/cre_uta_pdel_b/javacard/cre_uta_pdel_b.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/Api_3_Hbd_Bthdbs_1.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/Api_3_Hbd_Bthdbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..99aa851e40a700b4073aa14fcb15c596f367d120 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/Api_3_Hbd_Bthdbs_1.java @@ -0,0 +1,132 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_hbd_bthdbs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.system package, HandlerBuilder class, buildTLVHandler() method + * applet 1 + */ +public class Api_3_Hbd_Bthdbs_1 extends TestToolkitApplet { + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] HandlerBuffer = {(byte)0x02, (byte)0x04, (byte)0xAA, (byte)0xBB, (byte)0x11, (byte)0x22, (byte)0x33 }; + public final static short HANDLER_CAPACITY = (short)10; + public final static short NEGATIVE_CAPACITY = (short)-10; + + + // Constructor of the applet + public Api_3_Hbd_Bthdbs_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // Create a new applet instance + Api_3_Hbd_Bthdbs_1 thisApplet = new Api_3_Hbd_Bthdbs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + ViewHandler testObject; + + /** test case 1: Call buildTLVHandler() method with EDIT_HANDLER type */ + testCaseNb = (byte)0x01; + bRes = true; + try { + testObject = (EditHandler)HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY); + if (testObject == null) { + bRes = false; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 2: Call buildTLVHandler() method with BER_EDIT_HANDLER type */ + testCaseNb = (byte)0x02; + bRes = true; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, HANDLER_CAPACITY); + if (testObject == null) { + bRes = false; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 3: Negative capacity */ + testCaseNb = (byte)0x03; + bRes = false; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, NEGATIVE_CAPACITY); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 4: Type does not match with predefined values (3) */ + testCaseNb = (byte)0x04; + bRes = false; + try { + testObject = HandlerBuilder.buildTLVHandler((byte)3, HANDLER_CAPACITY); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 5: Type does not match with predefined values (0) */ + testCaseNb = (byte)0x05; + bRes = false; + try { + testObject = HandlerBuilder.buildTLVHandler((byte)0, HANDLER_CAPACITY); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/Test_Api_3_Hbd_Bthdbs.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/Test_Api_3_Hbd_Bthdbs.java new file mode 100644 index 0000000000000000000000000000000000000000..63413f9c1754c601c0c96bcc9caf3c39d4f1eb95 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/Test_Api_3_Hbd_Bthdbs.java @@ -0,0 +1,73 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.system package part 4 + * Test source for HandlerBuilder class + * buildTLVHandler(byte type, short capacity) method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_hbd_bthdbs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_3_Hbd_Bthdbs extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/system/api_3_hbd_bthdbs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 30010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 30010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_3_Hbd_Bthdbs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // test case 1 to 5: trigger applet1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05CCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..72d951419cb8b6d026db5736015d3172a68329e2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x01:0x00:0x01 uicc.test.system.api_3_hbd_bthdbs.Api_3_Hbd_Bthdbs_1 +uicc.test.system.api_3_hbd_bthdbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/javacard/api_3_hbd_bthdbs.cap b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/javacard/api_3_hbd_bthdbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..ef89d5a4beb6d6d1a06165dfa6cf48cd3e96dfb9 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs/javacard/api_3_hbd_bthdbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/Api_3_Hbd_Bthdbs_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/Api_3_Hbd_Bthdbs_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7a5cf5fde3a2f1df71ed0cac98e7ac3b7b5b38e6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/Api_3_Hbd_Bthdbs_Bss_1.java @@ -0,0 +1,262 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_hbd_bthdbs_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.system package, HandlerBuilder class, buildTLVHandler() method + * applet 1 + */ +public class Api_3_Hbd_Bthdbs_Bss_1 extends TestToolkitApplet { + + + private byte testCaseNb = (byte) 0x00; + private static boolean bRes; + private static byte[] HandlerBuffer = {(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)5, (byte)6, (byte)7, (byte)8, (byte)9}; + private byte copyBuffer[] = new byte[HANDLER_CAPACITY] ; + public final static short HANDLER_CAPACITY = (short)10; + public final static short NEGATIVE_CAPACITY = (short)-10; + + /** + * Constructor of the applet + */ + public Api_3_Hbd_Bthdbs_Bss_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // create a new applet instance + Api_3_Hbd_Bthdbs_Bss_1 thisApplet = new Api_3_Hbd_Bthdbs_Bss_1(); + + // register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // initialise the data of the test applet + thisApplet.init(); + + // registration to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + ViewHandler testObject; + EditHandler testHandler; + short length = (short)0; + short offset = (short)0; + short result = (short)0; + + + /** test case 1: Call buildTLVHandler() method with EDIT_HANDLER type */ + testCaseNb = (byte)0x01; + bRes = true; + offset = (short)0; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + if (testObject == null) { + bRes = false; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 2: Call buildTLVHandler() method with BER_EDIT_HANDLER type */ + testCaseNb = (byte)0x02; + bRes = true; + offset = (short)0; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + if (testObject == null) { + bRes = false; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 3: Negative capacity */ + testCaseNb = (byte)0x03; + bRes = false; + offset = (short)0; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, NEGATIVE_CAPACITY, + HandlerBuffer, offset, length); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 4: Type does not match with predefined values (0) */ + testCaseNb = (byte)0x04; + bRes = false; + offset = (short)0; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler((byte)0, HANDLER_CAPACITY, HandlerBuffer, offset, length); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 5: Type does not match with predefined values (3) */ + testCaseNb = (byte)0x05; + bRes = false; + offset = (short)0; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler((byte)3, HANDLER_CAPACITY, HandlerBuffer, offset, length); + } + catch (SystemException e) { + if (e.getReason() == SystemException.ILLEGAL_VALUE) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 6: Internal Buffer starts at bOffset */ + testCaseNb = (byte)0x06; + bRes = false; + offset = (short)4; + length = (short)5; + try { + testHandler = (EditHandler)HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + // Copy the EditHandler in copyBuffer + short copyBufferOffset = (short)0 ; + short copyBufferLength = (short)testHandler.getLength() ; + testHandler.copy(copyBuffer, copyBufferOffset, copyBufferLength) ; + // Compare copyBuffer to HandlerBuffer + result = javacard.framework.Util.arrayCompare(copyBuffer, copyBufferOffset, HandlerBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 7: Buffer is null */ + testCaseNb = (byte)0x07; + bRes = false; + offset = (short)0; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + null, offset, length); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 8: bOffset > Buffer Length */ + testCaseNb = (byte)0x08; + bRes = false; + offset = (short)11; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 9: bOffset < 0 */ + testCaseNb = (byte)0x09; + bRes = false; + offset = (short)-1; + length = (short)0; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 10: bLength < 0 */ + testCaseNb = (byte)0x0A; + bRes = false; + offset = (short)0; + length = (short)-1; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 11: bOffset+bLength > buffer length */ + testCaseNb = (byte)0x0B; + bRes = false; + offset = (short)7; + length = (short)8; + try { + testObject = HandlerBuilder.buildTLVHandler(HandlerBuilder.EDIT_HANDLER, HANDLER_CAPACITY, + HandlerBuffer, offset, length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/Test_Api_3_Hbd_Bthdbs_Bss.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/Test_Api_3_Hbd_Bthdbs_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..8b40305d01a8ea8abbdc42c5d300fd65f84e7621 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/Test_Api_3_Hbd_Bthdbs_Bss.java @@ -0,0 +1,71 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.system package part 4 + * Test source for HandlerBuilder class + * buildTLVHandler(byte type, short capacity, byte[] buffer, short bOffset, short bLength) method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_hbd_bthdbs_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +public class Test_Api_3_Hbd_Bthdbs_Bss extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/system/api_3_hbd_bthdbs_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 30010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 30010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_3_Hbd_Bthdbs_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // test case 1 to 11: trigger applet1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0BCCCCCC CCCCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c51817b69d51e3fe393012d32ac693f163110179 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x01:0x00:0x01 uicc.test.system.api_3_hbd_bthdbs_bss.Api_3_Hbd_Bthdbs_Bss_1 +uicc.test.system.api_3_hbd_bthdbs_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/javacard/api_3_hbd_bthdbs_bss.cap b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/javacard/api_3_hbd_bthdbs_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..777aba8ae7444616c125785574c99ef9e8c281ac Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/system/api_3_hbd_bthdbs_bss/javacard/api_3_hbd_bthdbs_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Api_3_Upf_Gvba_1.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Api_3_Upf_Gvba_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f7d48c33c4a40afb160bca1a1e088c9df38e0a12 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Api_3_Upf_Gvba_1.java @@ -0,0 +1,170 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_upf_gvba; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + + +public class Api_3_Upf_Gvba_1 extends TestToolkitApplet + implements Api_ShareableInterface { + + private byte testCaseNb; + private static boolean bRes; + static byte[] classVariable; + byte[] instanceVariable; + Object[] arrayComponent = new Object[1]; + + // Constructor of the applet + public Api_3_Upf_Gvba_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength){ + + // Create a new applet instance + Api_3_Upf_Gvba_1 thisApplet = new Api_3_Upf_Gvba_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** test case 2: Method invoked from a different context */ + public Shareable getShareableInterfaceObject(AID clientAid, byte parameter) { + byte[] baServerAid = {(byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x09, (byte)0x00, (byte)0x05, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0x89, + (byte)0x30, (byte)0x11, (byte)0x01, (byte)0x02}; + + if (((clientAid == null) && (parameter == (byte)0x01)) || + ((clientAid != null) && (clientAid.equals(baServerAid, (short)0, (byte)(baServerAid.length)) == true))) { + return this; + } else { + return null; + } + } + + public boolean getVolByteArray() { + byte[] localVariable; + boolean bRes; + testCaseNb = (byte)0x05; + + bRes= false; + try { + localVariable = UICCPlatform.getTheVolatileByteArray(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + return (bRes); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + byte[] localVariable; + + /** test case 1: Call getTheVolatileByteArray() method */ + testCaseNb = (byte)0x01; + bRes = false; + try { + localVariable = UICCPlatform.getTheVolatileByteArray(); + if (localVariable.length >= 256) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 3: Store the instance in a class variable */ + testCaseNb = (byte)0x02; + bRes = false; + try { + classVariable = UICCPlatform.getTheVolatileByteArray(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 4: Store the instance in an instance variable */ + testCaseNb = (byte)0x03; + bRes = false; + try { + instanceVariable = UICCPlatform.getTheVolatileByteArray(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + /** test case 5: Store the instance in an array component */ + testCaseNb = (byte)0x04; + bRes = false; + try { + arrayComponent[0] = UICCPlatform.getTheVolatileByteArray(); + } + catch (SecurityException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + } + + private short callNumber = 0; + + public void process(APDU apdu) { + + byte[] localVariable; + + if (callNumber++ == 0){ + testCaseNb = (byte)0x06; + bRes = false; + try { + localVariable = UICCPlatform.getTheVolatileByteArray(); + if (localVariable.length >= 256) { + bRes = true; + } + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb,bRes); + } + else + super.process(apdu); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Api_ShareableInterface.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Api_ShareableInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..9f2752624e8b6856230bd4e0b0efc90430d8e053 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Api_ShareableInterface.java @@ -0,0 +1,15 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_upf_gvba; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; + + +public interface Api_ShareableInterface extends javacard.framework.Shareable { + + public boolean getVolByteArray(); +} diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Test_Api_3_Upf_Gvba.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Test_Api_3_Upf_Gvba.java new file mode 100644 index 0000000000000000000000000000000000000000..8347cbeb45b9d633b2912d82ffb6e8f9715e7d67 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/Test_Api_3_Upf_Gvba.java @@ -0,0 +1,102 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.system package part 4 + * Test source for UICCPlatform class + * getTheVolatileByteArray() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_upf_gvba; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +// Interface UICCPlatform, Method getTheVolatileByteArray() + +public class Test_Api_3_Upf_Gvba extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/system/api_3_upf_gvba"; + static final String CAP_FILE_PATH2 = "uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 30010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 30010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 30110001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 30110102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_3_Upf_Gvba() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // install client package and applet for shareable test case + test.loadPackage(CAP_FILE_PATH2); + test.installApplet(CAP_FILE_PATH2, CLASS_AID_2, APPLET_AID_2, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // test case 1, 3 to 5: trigger applet1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // test case 2: select client applet. It calls applet1 shared method. + test.selectApplication(APPLET_AID_2); + result &= response.checkSw("9000"); + + // test case 1: select applet1 + response = test.selectApplication(APPLET_AID_1); + result &= response.checkSw("9000"); + + + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "06CCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/Api_GetShareableClientApplet.java b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/Api_GetShareableClientApplet.java new file mode 100644 index 0000000000000000000000000000000000000000..f7a97b1c25486f015316dbb2f5563e74f238983f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/Api_GetShareableClientApplet.java @@ -0,0 +1,48 @@ +// ----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.system.api_3_upf_gvba.api_3_upf_gvba2; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.test.system.api_3_upf_gvba.*; + +public class Api_GetShareableClientApplet extends javacard.framework.Applet { + + Api_ShareableInterface myShareObject; + + // Constructor of the applet + public Api_GetShareableClientApplet() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_GetShareableClientApplet thisApplet = new Api_GetShareableClientApplet(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset + 1), bArray[bOffset]); + } + + /** + * Method called by the JCRE at the selection of the applet + */ + public void process(APDU apdu) { + byte[] baServerAid = {(byte) 0xA0, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0x09, (byte) 0x00, (byte) 0x05, (byte) 0xFF, + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x89, + (byte) 0x30, (byte) 0x01, (byte) 0x01, (byte) 0x02}; + + AID serverAppletAid = new AID(baServerAid, (short) 0, + (byte) baServerAid.length); + + myShareObject = (Api_ShareableInterface) JCSystem + .getAppletShareableInterfaceObject(serverAppletAid, (byte) 0x01); + myShareObject.getVolByteArray(); + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/applet.opt b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..cd16a0ff3ab6db7a3beaeb0273a61562a7cad271 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x11:0x00:0x01 uicc.test.system.api_3_upf_gvba.api_3_upf_gvba2.Api_GetShareableClientApplet +uicc.test.system.api_3_upf_gvba.api_3_upf_gvba2 +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x11:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/javacard/api_3_upf_gvba2.cap b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/javacard/api_3_upf_gvba2.cap new file mode 100644 index 0000000000000000000000000000000000000000..99c8c285139cd2a62dde0dbe383ba12de7776ff9 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/api_3_upf_gvba2/javacard/api_3_upf_gvba2.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/applet.opt b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2825160c50489b7afa2a87e18c538a9676d0f5bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x01:0x00:0x01 uicc.test.system.api_3_upf_gvba.Api_3_Upf_Gvba_1 +uicc.test.system.api_3_upf_gvba +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x30:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/javacard/api_3_upf_gvba.cap b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/javacard/api_3_upf_gvba.cap new file mode 100644 index 0000000000000000000000000000000000000000..ea3c4f4078cad784b185792f8b643d70fa931cc2 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/system/api_3_upf_gvba/javacard/api_3_upf_gvba.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/Api_2_Bte_Apda_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/Api_2_Bte_Apda_1.java new file mode 100644 index 0000000000000000000000000000000000000000..0cc62f3d57a5dbec657e912028ff2a38dfdc48e9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/Api_2_Bte_Apda_1.java @@ -0,0 +1,294 @@ +//----------------------------------------------------------------------------- +//api_2_bte_apda_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_apda; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.*; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Apda_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + BERTLVEditHandler bte_handler = null; + byte buffer[] = null; + byte compareBuffer[] = null; + + /** + * If AID length is not zero register applet with specified AID + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Apda_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Apda_1 applet = new Api_2_Bte_Apda_1(); + //register applet + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) {applet.register();} + else {applet.register(bArray, (short) (bOffset + 1), aidLen);} + applet.init(); + //register event unrecognize envelope + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + //- NULL buffer + try{ + bte_handler.appendArray(null,(short)0,(short)0); + } + catch(NullPointerException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x02; + buffer = new byte[5]; + Util.arrayFillNonAtomic(buffer,(short)0,(short)5,(byte)0xFF); + + try{ + //-offset > buffer.length + bte_handler.appendArray(buffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x03; + try{ + //-offset < 0 + bte_handler.appendArray(buffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x04; + try{ + //-length > buffer.length + bte_handler.appendArray(buffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x05; + try{ + //-offset + length > buffer.length + bte_handler.appendArray(buffer,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x06; + try{ + //- length < 0 + bte_handler.appendArray(buffer,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7-------------- + try { + bRes = false; + testCaseNb = (byte) 0x07; + buffer = new byte[(short)(bte_handler.getCapacity()+1)]; + try{ + //- Handler overflow exception + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()+1)); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8-------------- + try { + bRes = false; + testCaseNb = (byte) 0x08; + bte_handler.clear(); + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.appendArray(bArray,(short)0,(short)9); + //- select command details TLV (0x81) + bte_handler.findTLV((byte)0x81,(byte)0x01); + //- successfull call + buffer = new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0xF9,(byte)0xF8}; + bte_handler.appendArray(buffer,(short)0,(short)8); + //-verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9-------------- + try { + bRes = false; + testCaseNb = (byte) 0x09; + //-clear the handler + bte_handler.clear(); + compareBuffer = new byte[18]; + buffer = new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0xF9,(byte)0xF8}; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)8); + //-successful call + bte_handler.appendArray(buffer,(short)0,(short)8); + //-call copy() method + bte_handler.copy(buffer,(short)0,(short)8); + //-compare the array + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)8)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10-------------- + try { + bRes = false; + testCaseNb = (byte) 0x0A; + //-initialize compare buffer + buffer = new byte[]{(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07}; + Util.arrayCopy(buffer,(short)2,compareBuffer,(short)8,(short)6); + //-successful call + bte_handler.appendArray(buffer,(short)2,(short)6); + //-call copy() method + buffer=new byte[14]; + bte_handler.copy(buffer,(short)0,(short)14); + //-compare the array + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)14)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11-------------- + try { + bRes = false; + testCaseNb = (byte) 0x0B; + //-initialize compare buffer + buffer = new byte[]{(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55,(byte)0x66,(byte)0x77,(byte)0x88}; + Util.arrayCopy(buffer,(short)2,compareBuffer,(short)14,(short)4); + //-successful call + bte_handler.appendArray(buffer,(short)2,(short)4); + //-call copy() method + buffer=new byte[18]; + bte_handler.copy(buffer,(short)0,(short)18); + //-compare the array + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)18)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12-------------- + try { + bRes = false; + testCaseNb = (byte) 0x0C; + bte_handler.clear(); + bArray=new byte[(short)253]; + compareBuffer = new byte[(short)253]; + buffer=new byte[253]; + for(short i=0;i<(short)253;i++){ + bArray[i]=(byte)i; + } + Util.arrayCopy(bArray,(short)0,compareBuffer,(short)0,(short)253); + bte_handler.appendArray(bArray,(short)0,(short)253); + if((short)bte_handler.getLength()==(short)253){ + bte_handler.copy(buffer,(short)0,(short)253); + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/Test_Api_2_Bte_Apda.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/Test_Api_2_Bte_Apda.java new file mode 100644 index 0000000000000000000000000000000000000000..a6abfa0da924e54184ac880bc964d59f5093cd5f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/Test_Api_2_Bte_Apda.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Apda.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_apda; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +public class Test_Api_2_Bte_Apda extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_apda"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + + /** + * + */ + public Test_Api_2_Bte_Apda(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //install the test applet + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..33640431161db2f86fd39be13521b7db519214b0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_apda.Api_2_Bte_Apda_1 +uicc.test.toolkit.api_2_bte_apda +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/javacard/api_2_bte_apda.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/javacard/api_2_bte_apda.cap new file mode 100644 index 0000000000000000000000000000000000000000..e51d6545441c83f5ecadffac9e22a290916649b0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_apda/javacard/api_2_bte_apda.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/Api_2_Bte_Aptlb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/Api_2_Bte_Aptlb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6a179df2b8e1d07a7c67fd306f063e927334907b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/Api_2_Bte_Aptlb_Bss_1.java @@ -0,0 +1,346 @@ +//----------------------------------------------------------------------------- +//api_2_bte_aptlb_bss_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlb_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlb_Bss_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + */ + private Api_2_Bte_Aptlb_Bss_1 () {} + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlb_Bss_1 applet = new Api_2_Bte_Aptlb_Bss_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) {applet.register();} + else {applet.register(bArray, (short) (bOffset + 1), aidLen);} + applet.init(); + //register applet + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + //null value + try{ + bte_handler.appendTLV((byte)0x0D,null,(short)0,(short)0); + } + catch(NullPointerException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x02; + buffer = new byte[5]; + Util.arrayFillNonAtomic(buffer,(short)0,(short)5,(byte)0xFF); + try{ + //- valueOffset > value.length + bte_handler.appendTLV((byte)0x0D,buffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x03; + try{ + //- valueOffset < 0 + bte_handler.appendTLV((byte)0x0D,buffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x04; + try{ + //- valueOffset < 0 + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x05; + try{ + //- valueOffset + valueLength > value.length + bte_handler.appendTLV((byte)0x0D,buffer,(short)3,(short)3 ); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x06; + try{ + //- valueLength < 0 + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)-1 ); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x07; + buffer = new byte[(short)(bte_handler.getCapacity()-1)]; + Util.arrayFillNonAtomic(buffer,(short)0,(short)(bte_handler.getCapacity()-1),(byte)0xFF); + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + buffer = new byte[254]; + try{ + //- Handler overflow exception + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)254); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x08; + bte_handler.clear(); + + buffer = new byte[256]; + bte_handler.appendArray(buffer,(short)0,(short)256); + try{ + //- Bad parameter exception + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)256); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.BAD_INPUT_PARAMETER){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x09; + //- initialize the handler + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + bte_handler.appendArray(buffer,(short)0,(short)9); + //- select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //- successful call + buffer= new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0xF9,(byte)0xF8}; + bte_handler.appendTLV((byte)0x04,buffer,(short)0,(short)8); + //- verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0A; + //- clear the handler + bte_handler.clear(); + //- successful call + buffer= new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0xF9,(byte)0xF8}; + compareBuffer=new byte[24]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x08; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)2,(short)8); + bte_handler.appendTLV((byte)0x04,buffer,(short)0,(short)8); + buffer=new byte[10]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)10); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)10)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0B; + //- successful call + buffer= new byte[]{(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07}; + compareBuffer[10]=(byte)0x85; + compareBuffer[11]=(byte)0x06; + Util.arrayCopy(buffer,(short)2,compareBuffer,(short)12,(short)6); + bte_handler.appendTLV((byte)0x85,buffer,(short)2,(short)6); + buffer=new byte[18]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)18); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)18)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0C; + //- successful call + buffer= new byte[]{(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55,(byte)0x66,(byte)0x77,(byte)0x88}; + compareBuffer[18]=(byte)0x01; + compareBuffer[19]=(byte)0x04; + Util.arrayCopy(buffer,(short)2,compareBuffer,(short)20,(short)4); + bte_handler.appendTLV((byte)0x01,buffer,(short)2,(short)4); + buffer=new byte[24]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)24); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)24)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0D; + //- clear the handler + bte_handler.clear(); + //- successful call + buffer= new byte[128]; + for (short i=0; i<(short)128;i++){ + buffer[i]=(byte)i; + } + compareBuffer=new byte[131]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x81; + compareBuffer[2]=(byte)0x80; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)3,(short)128); + bte_handler.appendTLV((byte)0x04,buffer,(short)0,(short)128); + buffer=new byte[131]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)131); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)131)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 14 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0E; + //- clear the handler + bte_handler.clear(); + //- successful call + buffer= new byte[250]; + for (short i=0; i<(short)250;i++){ + buffer[i]=(byte)i; + } + compareBuffer=new byte[253]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x81; + compareBuffer[2]=(byte)0xFA; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)3,(short)250); + bte_handler.appendTLV((byte)0x04,buffer,(short)0,(short)250); + buffer=new byte[253]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)253); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/Test_Api_2_Bte_Aptlb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/Test_Api_2_Bte_Aptlb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..e11a2b6ae12a4e2696a634e4831677f4b3bd36ab --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/Test_Api_2_Bte_Aptlb_Bss.java @@ -0,0 +1,87 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlb_bss; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Aptlb_Bss extends UiccTestModel +{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlb_bss"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** terminal profile for this test */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** the UiccAPITestCardService */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + + /** + * + */ + public Test_Api_2_Bte_Aptlb_Bss(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..75a68fc30cd0b9081882921a73d40350f8c6b5f9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlb_bss.Api_2_Bte_Aptlb_Bss_1 +uicc.test.toolkit.api_2_bte_aptlb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/javacard/api_2_bte_aptlb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/javacard/api_2_bte_aptlb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..02f178c805da1f26ffeec698dfaf202e431ef873 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss/javacard/api_2_bte_aptlb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/Api_2_Bte_Aptlb_Bss_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/Api_2_Bte_Aptlb_Bss_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3ee164abbf34431048611d29ba26d72cf4386c43 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/Api_2_Bte_Aptlb_Bss_Bss_1.java @@ -0,0 +1,449 @@ +//----------------------------------------------------------------------------- +//api_2_bte_aptlb_bss_bss_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlb_bss_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlb_Bss_Bss_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer1[] = null; + byte buffer2[] = null; + + /** + */ + private Api_2_Bte_Aptlb_Bss_Bss_1 () {} + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlb_Bss_Bss_1 applet = new Api_2_Bte_Aptlb_Bss_Bss_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) {applet.register();} + else {applet.register(bArray, (short) (bOffset + 1), aidLen);} + //initialise the inherited test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer1 = new byte[5]; + buffer2 = new byte[5]; + try{ + //- null value1 + bte_handler.appendTLV((byte)0x0D,null,(short)0,(short)5,buffer2,(short)0,(short)5); + } + catch(NullPointerException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x02; + try{ + //- null value2 + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)5,null,(short)0,(short)5); + } + catch(NullPointerException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x03; + try{ + //-value1Offset >= value1.length + bte_handler.appendTLV((byte)0x0D,buffer1,(short)5,(short)1,buffer2,(short)0,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x04; + try{ + //-value1Offset < 0 + bte_handler.appendTLV((byte)0x0D,buffer1,(short)-1,(short)1,buffer2,(short)0,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x05; + try{ + //-value1Length > value1.length + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)6,buffer2,(short)0,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x06; + try{ + //-value1Offset + value1Length > value1.length + bte_handler.appendTLV((byte)0x0D,buffer1,(short)3,(short)3,buffer2,(short)0,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + // -------------- TESTCASE 7 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x07; + try{ + //-value1Length < 0 + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)-1,buffer2,(short)0,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + // -------------- TESTCASE 8 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x08; + try{ + //-value2Offset >= value2.length + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)1,buffer2,(short)5,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x09; + try{ + //-value2Ofsset < 0 + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)1,buffer2,(short)5,(short)-1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0A; + try{ + //-value2Length > value2.length + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)1,buffer2,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0B; + try{ + //-value2Offset + value2Length > value2.length + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)1,buffer2,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0C; + try{ + //-value2Length <0 + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)1,buffer2,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0D; + buffer1=new byte[(short)(bte_handler.getCapacity()-1)]; + bte_handler.appendArray(buffer1,(short)0,(short)(bte_handler.getCapacity()-1)); + buffer1= new byte[256]; + buffer2= new byte[256]; + + try{ + //-Handler overflow exeption + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)253,buffer2,(short)0,(short)1); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 14 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0E; + bte_handler.clear(); + buffer1= new byte[256]; + buffer2= new byte[256]; + try{ + //-Bad parameter exception + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)256,buffer2,(short)0,(short)1); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.BAD_INPUT_PARAMETER){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 15 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0F; + bte_handler.clear(); + buffer1= new byte[256]; + buffer2= new byte[256]; + try{ + //-Bad parameter exception + bte_handler.appendTLV((byte)0x0D,buffer1,(short)0,(short)1,buffer2,(short)0,(short)256); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.BAD_INPUT_PARAMETER){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 16 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x10; + bte_handler.clear(); + bte_handler.appendTLV((byte)0x81,new byte[]{(byte)0x11,(byte)0x22,(byte)0x33},(short)0,(short)3); + bte_handler.appendTLV((byte)0x82,new byte[]{(byte)0x99,(byte)0x77,},(short)0,(short)2); + //-select Command details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-successful call + buffer1= new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0x09,(byte)0x08}; + buffer2= new byte[]{(byte)0xF7,(byte)0xF6,(byte)0xF5,(byte)0xF4,(byte)0xF3,(byte)0xF2,(byte)0xF1,(byte)0xF0}; + bte_handler.appendTLV((byte)0x04,buffer1,(short)0,(short)8,buffer2,(short)0,(short)8); + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 17 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x11; + bte_handler.clear(); + //-successful call + buffer1= new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0x09,(byte)0x08}; + buffer2= new byte[]{(byte)0xF7,(byte)0xF6,(byte)0xF5,(byte)0xF4,(byte)0xF3,(byte)0xF2,(byte)0xF1,(byte)0xF0}; + compareBuffer = new byte[42]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x10; + Util.arrayCopy(buffer1,(short)0,compareBuffer,(short)2,(short)8); + Util.arrayCopy(buffer2,(short)0,compareBuffer,(short)10,(short)8); + bte_handler.appendTLV((byte)0x04,buffer1,(short)0,(short)8,buffer2,(short)0,(short)8); + buffer1= new byte[18]; + bte_handler.copy(buffer1,(short)0,(short)18); + //-compare buffer + if(Util.arrayCompare(buffer1,(short)0,compareBuffer,(short)0,(short)18)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 18 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x12; + + //-successful call + buffer1= new byte[]{(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07}; + buffer2= new byte[]{(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + compareBuffer[18]=(byte)0x85; + compareBuffer[19]=(byte)0x0C; + Util.arrayCopy(buffer1,(short)2,compareBuffer,(short)20,(short)6); + Util.arrayCopy(buffer2,(short)2,compareBuffer,(short)26,(short)6); + bte_handler.appendTLV((byte)0x85,buffer1,(short)2,(short)6,buffer2,(short)2,(short)6); + buffer1= new byte[32]; + bte_handler.copy(buffer1,(short)0,(short)32); + //-compare buffer + if(Util.arrayCompare(buffer1,(short)0,compareBuffer,(short)0,(short)32)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 19 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x13; + //-successful call + buffer1= new byte[]{(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55,(byte)0x66,(byte)0x77,(byte)0x88}; + buffer2= new byte[]{(byte)0x99,(byte)0xAA,(byte)0xBB,(byte)0xCC,(byte)0xDD,(byte)0xEE,(byte)0xFF,(byte)0x00}; + compareBuffer[32]=(byte)0x01; + compareBuffer[33]=(byte)0x08; + Util.arrayCopy(buffer1,(short)2,compareBuffer,(short)34,(short)4); + Util.arrayCopy(buffer2,(short)2,compareBuffer,(short)38,(short)4); + bte_handler.appendTLV((byte)0x01,buffer1,(short)2,(short)4,buffer2,(short)2,(short)4); + buffer1= new byte[42]; + bte_handler.copy(buffer1,(short)0,(short)42); + //-compare buffer + if(Util.arrayCompare(buffer1,(short)0,compareBuffer,(short)0,(short)42)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 20 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x14; + //-successful call + bte_handler.clear(); + buffer1 = new byte[128]; + buffer2 = new byte[125]; + compareBuffer= new byte[256]; + for (short i=0;i<128;i++){ + buffer1[i]=(byte)i; + } + for (short i=128;i<253;i++){ + buffer2[(short)(i-128)]=(byte)i; + } + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x81; + compareBuffer[2]=(byte)0xFD; + Util.arrayCopy(buffer1,(short)0,compareBuffer,(short)3,(short)128); + Util.arrayCopy(buffer2,(short)0,compareBuffer,(short)131,(short)125); + //-successful call + bte_handler.appendTLV((byte)0x04,buffer1,(short)0,(short)128,buffer2,(short)0,(short)125); + buffer1= new byte[256]; + bte_handler.copy(buffer1,(short)0,(short)256); + //-compare buffer + if(Util.arrayCompare(buffer1,(short)0,compareBuffer,(short)0,(short)256)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/Test_Api_2_Bte_Aptlb_Bss_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/Test_Api_2_Bte_Aptlb_Bss_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..9bce6173ebd1ead1b1a74ac9230e409e2f0902b9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/Test_Api_2_Bte_Aptlb_Bss_Bss.java @@ -0,0 +1,87 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlb_Bss_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlb_bss_bss; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + + +public class Test_Api_2_Bte_Aptlb_Bss_Bss extends UiccTestModel +{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlb_bss_bss"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** terminal profile for this test */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** the UiccAPITestCardService */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + + /** + * + */ + public Test_Api_2_Bte_Aptlb_Bss_Bss(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "14CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC " + + "CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..1b32ff016a7d00adca8efca46ba8a14fdda955ac --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlb_bss_bss.Api_2_Bte_Aptlb_Bss_Bss_1 +uicc.test.toolkit.api_2_bte_aptlb_bss_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/javacard/api_2_bte_aptlb_bss_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/javacard/api_2_bte_aptlb_bss_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..3f4aabf97623abc65dca4dab1cca26b6b1694e67 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlb_bss_bss/javacard/api_2_bte_aptlb_bss_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/Api_2_Bte_Aptlbb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/Api_2_Bte_Aptlbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..85aa4889a53a817b8f9c09f612987eb33388d8c7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/Api_2_Bte_Aptlbb_1.java @@ -0,0 +1,189 @@ +//----------------------------------------------------------------------------- +//api_2_bte_aptlbb_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbb; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlbb_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + * If AID length is not zero register applet with specified AID + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Aptlbb_1 () { + } + /** + * Create an instance of the BaService, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlbb_1 applet = new Api_2_Bte_Aptlbb_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialise the test applet values + applet.init(); + //register applet + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer=new byte[(short)(bte_handler.getCapacity()-1)]; + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + //cause Handler Overflow + try{ + bte_handler.appendTLV((byte)0x0D,(byte)0x00); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x02; + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + //initialize the handler + bte_handler.appendArray(buffer,(short)0,(short)9); + //-select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-call appendTLV() + bte_handler.appendTLV((byte)0x0E,(byte)0x00); + //-verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x03; + bte_handler.clear(); + bte_handler.appendTLV((byte)0x84,(byte)0x00); + buffer= new byte[3]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x01,(byte)0x00}; + bte_handler.copy(buffer,(short)0,(short)3); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)3)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x04; + //-succesful call + bte_handler.appendTLV((byte)0x01,(byte)0xFE); + buffer= new byte[6]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x01,(byte)0x00,(byte)01,(byte)0x01,(byte)0xFE}; + //-call copy method + bte_handler.copy(buffer,(short)0,(short)6); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)6)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 5 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x05; + buffer = new byte[250]; + compareBuffer=new byte[253]; + bte_handler.clear(); + buffer[0]=(byte)0x00; + buffer[1]=(byte)0x81; + buffer[2]=(byte)0xF7; + for(short i=3;i<250;i++){ + buffer[i]=(byte)i; + } + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)250); + compareBuffer[250]=(byte)0x84; + compareBuffer[251]=(byte)0x01; + compareBuffer[252]=(byte)0x00; + //-call appendArray + bte_handler.appendArray(buffer,(short)0,(short)250); + //-successful call + bte_handler.appendTLV((byte)0x84,(byte)0x00); + //-call getLength() + if(bte_handler.getLength()==(short)253){ + buffer= new byte[253]; + bte_handler.copy(buffer,(short)0,(short)253); + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + + + + + + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/Test_Api_2_Bte_Aptlbb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/Test_Api_2_Bte_Aptlbb.java new file mode 100644 index 0000000000000000000000000000000000000000..e160c5de83d421dad125fb2edf317905f201c3b0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/Test_Api_2_Bte_Aptlbb.java @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlbb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbb; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Aptlbb extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlbb"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Aptlbb(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+"05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ab7976113af93321b480ddb6bf33f4853cc2c983 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlbb.Api_2_Bte_Aptlbb_1 +uicc.test.toolkit.api_2_bte_aptlbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/javacard/api_2_bte_aptlbb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/javacard/api_2_bte_aptlbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..342b87ab0fc31473bfd3a738b1d7b193a096af32 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb/javacard/api_2_bte_aptlbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/Api_2_Bte_Aptlbb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/Api_2_Bte_Aptlbb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..aace85a8450c712ff8e42e1dea62f5bed0873eda --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/Api_2_Bte_Aptlbb_Bss_1.java @@ -0,0 +1,366 @@ +//----------------------------------------------------------------------------- +//api_2_bte_aptlbb_bss_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbb_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlbb_Bss_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + * If AID length is not zero register applet with specified AID + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Aptlbb_Bss_1 () { + + } + /** + * Create an instance of the BaService, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlbb_Bss_1 applet = new Api_2_Bte_Aptlbb_Bss_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + ; + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + //null value + try{ + bte_handler.appendTLV((byte)0x0D,(byte)0x00,null,(short)0,(short)1); + } + catch(NullPointerException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x02; + buffer = new byte[5]; + Util.arrayFillNonAtomic(buffer,(short)0,(short)5,(byte)0xFF); + try{ + //- value2Offset > value2.length + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 3 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x03; + try{ + //- value2Offset < 0 + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x04; + try{ + //- value2Offset < 0 + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x05; + try{ + //- value2Offset + value2Length > value2.length + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)3,(short)3 ); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x06; + try{ + //- value2Length < 0 + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)0,(short)-1 ); + } + catch(ArrayIndexOutOfBoundsException ex){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x07; + buffer = new byte[(short)(bte_handler.getCapacity()-1)]; + Util.arrayFillNonAtomic(buffer,(short)0,(short)(bte_handler.getCapacity()-1),(byte)0xFF); + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + buffer = new byte[254]; + try{ + //- Handler overflow exception + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)0,(short)254); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x08; + bte_handler.clear(); + + buffer = new byte[256]; + bte_handler.appendArray(buffer,(short)0,(short)256); + try{ + //- Bad parameter exception + bte_handler.appendTLV((byte)0x0D,(byte)0x00,buffer,(short)0,(short)256); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.BAD_INPUT_PARAMETER){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 9 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x09; + //- initialize the handler + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + bte_handler.appendArray(buffer,(short)0,(short)9); + //- select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //- successful call + buffer= new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0xF9,(byte)0xF8}; + bte_handler.appendTLV((byte)0x04,(byte)0x05,buffer,(short)0,(short)8); + //- verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0A; + //- clear the handler + bte_handler.clear(); + //- successful call + buffer= new byte[]{(byte)0xFF,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB,(byte)0xFA,(byte)0xF9,(byte)0xF8}; + compareBuffer=new byte[27]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x09; + compareBuffer[2]=(byte)0x05; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)3,(short)8); + bte_handler.appendTLV((byte)0x04,(byte)0x05,buffer,(short)0,(short)8); + buffer=new byte[11]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)11); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)11)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0B; + //- successful call + buffer= new byte[]{(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07}; + compareBuffer[11]=(byte)0x85; + compareBuffer[12]=(byte)0x07; + compareBuffer[13]=(byte)0x55; + Util.arrayCopy(buffer,(short)2,compareBuffer,(short)14,(short)6); + bte_handler.appendTLV((byte)0x85,(byte)0x55,buffer,(short)2,(short)6); + buffer=new byte[20]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)20); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)20)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0C; + //- successful call + buffer= new byte[]{(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55,(byte)0x66,(byte)0x77,(byte)0x88}; + compareBuffer[20]=(byte)0x01; + compareBuffer[21]=(byte)0x05; + compareBuffer[22]=(byte)0x44; + Util.arrayCopy(buffer,(short)2,compareBuffer,(short)23,(short)4); + bte_handler.appendTLV((byte)0x01,(byte)0x44,buffer,(short)2,(short)4); + buffer=new byte[27]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)27); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)27)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 13 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0D; + //- clear the handler + bte_handler.clear(); + //- successful call + buffer= new byte[127]; + for (short i=1; i<(short)128;i++){ + buffer[(short)(i-1)]=(byte)i; + } + compareBuffer=new byte[131]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x81; + compareBuffer[2]=(byte)0x80; + compareBuffer[3]=(byte)0x00; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)4,(short)127); + bte_handler.appendTLV((byte)0x04,(byte)0x00,buffer,(short)0,(short)127); + buffer=new byte[131]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)131); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)131)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 14 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0E; + //- clear the handler + bte_handler.clear(); + //- successful call + buffer= new byte[249]; + for (short i=1; i<(short)250;i++){ + buffer[(short)(i-1)]=(byte)i; + } + compareBuffer=new byte[253]; + compareBuffer[0]=(byte)0x04; + compareBuffer[1]=(byte)0x81; + compareBuffer[2]=(byte)0xFA; + compareBuffer[3]=(byte)0x00; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)4,(short)249); + bte_handler.appendTLV((byte)0x04,(byte)0x00,buffer,(short)0,(short)249); + buffer=new byte[253]; + //- call copy() method + bte_handler.copy(buffer,(short)0,(short)253); + if (Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + + + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/Test_Api_2_Bte_Aptlbb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/Test_Api_2_Bte_Aptlbb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..61aa276640981653e7415dba6395598cf05036e8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/Test_Api_2_Bte_Aptlbb_Bss.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlbb_bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbb_bss; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Aptlbb_Bss extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlbb_bss"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Aptlbb_Bss(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+ + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c0d5faa7786c74bb5fd84f55d4125b3e476007f2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlbb_bss.Api_2_Bte_Aptlbb_Bss_1 +uicc.test.toolkit.api_2_bte_aptlbb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/javacard/api_2_bte_aptlbb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/javacard/api_2_bte_aptlbb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..2c1c4fdafb08df6eb428238b4271b91c78152844 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbb_bss/javacard/api_2_bte_aptlbb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/Api_2_Bte_Aptlbbb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/Api_2_Bte_Aptlbbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..571917017d6d0d104945d65f8ed50d9c0d3499fb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/Api_2_Bte_Aptlbbb_1.java @@ -0,0 +1,182 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Aptlbbb_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbbb; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlbbb_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + */ + private Api_2_Bte_Aptlbbb_1 () {} + /** + * Create an instance of the BaService, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlbbb_1 applet = new Api_2_Bte_Aptlbbb_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event event_unrecognized_envelope + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer=new byte[(short)(bte_handler.getCapacity()-1)]; + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + //cause Handler Overflow + try{ + bte_handler.appendTLV((byte)0x0D,(byte)0x00); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x02; + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + //initialize the handler + bte_handler.appendArray(buffer,(short)0,(short)9); + //-select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-call appendTLV() + bte_handler.appendTLV((byte)0x0E,(byte)0x00,(byte)0x01); + //-verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x03; + bte_handler.clear(); + bte_handler.appendTLV((byte)0x84,(byte)0x00,(byte)0x01); + buffer= new byte[4]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x02,(byte)0x00,(byte)0x01}; + bte_handler.copy(buffer,(short)0,(short)4); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)4)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 4 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x04; + //-succesful call + bte_handler.appendTLV((byte)0x01,(byte)0xFE,(byte)0xFD); + buffer= new byte[8]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x02,(byte)0x00,(byte)0x01,(byte)01,(byte)0x02,(byte)0xFE,(byte)0xFD}; + //-call copy method + bte_handler.copy(buffer,(short)0,(short)8); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)8)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 5 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x05; + buffer = new byte[249]; + compareBuffer=new byte[253]; + bte_handler.clear(); + buffer[0]=(byte)0x00; + buffer[1]=(byte)0x81; + buffer[2]=(byte)0xF6; + for(short i=3;i<249;i++){ + buffer[i]=(byte)i; + } + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)249); + compareBuffer[249]=(byte)0x84; + compareBuffer[250]=(byte)0x02; + compareBuffer[251]=(byte)0x00; + compareBuffer[252]=(byte)0x01; + //-call appendArray + bte_handler.appendArray(buffer,(short)0,(short)249); + //-successful call + bte_handler.appendTLV((byte)0x84,(byte)0x00, (byte)0x01); + //-call getLength() + if(bte_handler.getLength()==(short)253){ + buffer= new byte[253]; + bte_handler.copy(buffer,(short)0,(short)253); + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + + + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/Test_Api_2_Bte_Aptlbbb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/Test_Api_2_Bte_Aptlbbb.java new file mode 100644 index 0000000000000000000000000000000000000000..4ea4c6b2173a24939e1485b22a93f61a9ebd30f0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/Test_Api_2_Bte_Aptlbbb.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlbbb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbbb; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_2_Bte_Aptlbbb extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlbbb"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Aptlbbb(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+ + "05CCCCCCCC CC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..41ea90dc43f28c2ee951ceb21affd1515866042d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlbbb.Api_2_Bte_Aptlbbb_1 +uicc.test.toolkit.api_2_bte_aptlbbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/javacard/api_2_bte_aptlbbb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/javacard/api_2_bte_aptlbbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..aa654989c6b1264f36b0fa3ebe725733c085fd77 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbb/javacard/api_2_bte_aptlbbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/Api_2_Bte_Aptlbbs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/Api_2_Bte_Aptlbbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..0063894f40ff8b13709d5d14e5013e2e080d0ce0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/Api_2_Bte_Aptlbbs_1.java @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Aptlbbs_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbbs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlbbs_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + */ + private Api_2_Bte_Aptlbbs_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlbbs_1 applet = new Api_2_Bte_Aptlbbs_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer = new byte[(short)(bte_handler.getCapacity()-1)]; + //cause Handler Overflow + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + try{ + bte_handler.appendTLV((byte)0x0D,(byte)0x00,(short)1); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x02; + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + //initialize the handler + bte_handler.appendArray(buffer,(short)0,(short)9); + //-select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-call appendTLV() + bte_handler.appendTLV((byte)0x0E,(byte)0x00,(short)1); + //-verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x03; + bte_handler.clear(); + bte_handler.appendTLV((byte)0x84,(byte)0x00,(short)Util.makeShort((byte)0x01,(byte)0x02)); + buffer= new byte[]{(byte)0x84,(byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02}; + compareBuffer=new byte[10]; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)5); + bte_handler.copy(buffer,(short)0,(short)5); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)5)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x04; + bte_handler.appendTLV((byte)0x01,(byte)0xFE,(short)Util.makeShort((byte)0xFD,(byte)0xFC)); + Util.arrayCopy( new byte[]{(byte)0x01,(byte)0x03,(byte)0xFE,(byte)0xFD,(byte)0xFC },(short)0,compareBuffer,(short)5,(short)5); + buffer=new byte[10]; + bte_handler.copy(buffer,(short)0,(short)10); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)10)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 5 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x05; + bte_handler.clear(); + buffer=new byte[248]; + buffer[0]=(byte)0x00; + buffer[1]=(byte)0x81; + buffer[2]=(byte)0xF5; + for (short i=3;i<248;i++){ + buffer[i]=(byte)i; + } + bte_handler.appendArray(buffer,(short)0,(short)248); + compareBuffer=new byte[253]; + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)248); + compareBuffer[248]=(byte)0x84; + compareBuffer[249]=(byte)0x03; + compareBuffer[250]=(byte)0x00; + compareBuffer[251]=(byte)0x01; + compareBuffer[252]=(byte)0x02; + bte_handler.appendTLV((byte)0x84,(byte)0x00,Util.makeShort((byte)0x01,(byte)0x02)); + buffer=new byte[253]; + bte_handler.copy(buffer,(short)0,(short)253); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/Test_Api_2_Bte_Aptlbbs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/Test_Api_2_Bte_Aptlbbs.java new file mode 100644 index 0000000000000000000000000000000000000000..ccac233a5e3128dd970794a296c8323ec3267d35 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/Test_Api_2_Bte_Aptlbbs.java @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlbbs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbbs; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + + +public class Test_Api_2_Bte_Aptlbbs extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlbbs"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Aptlbbs(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + //); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+ + "05CCCCCC CCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5097cdda43b678497ab83f5da474ad66bda3de18 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlbbs.Api_2_Bte_Aptlbbs_1 +uicc.test.toolkit.api_2_bte_aptlbbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/javacard/api_2_bte_aptlbbs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/javacard/api_2_bte_aptlbbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..8db4280d9476fc34a78b4135d0bb8c2072f31cfe Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbbs/javacard/api_2_bte_aptlbbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/Api_2_Bte_Aptlbs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/Api_2_Bte_Aptlbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..54ecba9afca6d209adbcd9d942bcdbbb788b6cf8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/Api_2_Bte_Aptlbs_1.java @@ -0,0 +1,178 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Aptlbs_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlbs_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + */ + private Api_2_Bte_Aptlbs_1 () { + } + /** + * Create an instance of the BaService, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlbs_1 applet = new Api_2_Bte_Aptlbs_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialise the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer=new byte[(short)(bte_handler.getCapacity()-1)]; + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + //cause Handler Overflow + try{ + bte_handler.appendTLV((byte)0x0D,(short)1); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x02; + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + //initialize the handler + bte_handler.appendArray(buffer,(short)0,(short)9); + //-select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-call appendTLV() + bte_handler.appendTLV((byte)0x0E,(short)0); + //-verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x03; + //- clear the handler + bte_handler.clear(); + bte_handler.appendTLV((byte)0x84,Util.makeShort((byte)0x00,(byte)0x01)); + buffer= new byte[4]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x02,(byte)0x00,(byte)0x01}; + bte_handler.copy(buffer,(short)0,(short)4); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)4)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x04; + //-succesful call + bte_handler.appendTLV((byte)0x01,Util.makeShort((byte)0xFE,(byte)0xFF)); + buffer= new byte[8]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x02,(byte)0x00,(byte)01,(byte)01,(byte)0x02,(byte)0xFE,(byte)0xFF}; + //-call copy method + bte_handler.copy(buffer,(short)0,(short)8); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)8)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x05; + buffer = new byte[249]; + compareBuffer=new byte[253]; + bte_handler.clear(); + buffer[0]=(byte)0x00; + buffer[1]=(byte)0x81; + buffer[2]=(byte)0xF6; + for(short i=3;i<249;i++){ + buffer[3]=(byte)i; + } + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)249); + compareBuffer[249]=(byte)0x84; + compareBuffer[250]=(byte)0x02; + compareBuffer[251]=(byte)0x00; + compareBuffer[252]=(byte)0x01; + //-call appendArray + bte_handler.appendArray(buffer,(short)0,(short)249); + //-successful call + bte_handler.appendTLV((byte)0x84,Util.makeShort((byte)0x00,(byte)0x01)); + //-call getLength() + if(bte_handler.getLength()==(short)253){ + buffer= new byte[253]; + bte_handler.copy(buffer,(short)0,(short)253); + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/Test_Api_2_Bte_Aptlbs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/Test_Api_2_Bte_Aptlbs.java new file mode 100644 index 0000000000000000000000000000000000000000..fe0678930b61ece076a57eada9867cb60c567110 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/Test_Api_2_Bte_Aptlbs.java @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlbbs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbs; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Aptlbs extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlbs"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Aptlbs(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + //Install package + test.loadPackage(CAP_FILE_PATH); + test.terminalProfileSession("13"); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+ + "05CCCCCC CCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..1fb8b64f206c6910ecf9b5a07cfc97cdcbf49638 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlbs.Api_2_Bte_Aptlbs_1 +uicc.test.toolkit.api_2_bte_aptlbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/javacard/api_2_bte_aptlbs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/javacard/api_2_bte_aptlbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..dee0b68f414aca216627936ab468eab7999b6821 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbs/javacard/api_2_bte_aptlbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/Api_2_Bte_Aptlbss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/Api_2_Bte_Aptlbss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..edd2d28cea07d1b07ceeab35e011734b0d32a9ed --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/Api_2_Bte_Aptlbss_1.java @@ -0,0 +1,189 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Aptlbss_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Aptlbss_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + * If AID length is not zero register applet with specified AID + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Aptlbss_1 () { + } + /** + * Create an instance of the BaService, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Aptlbss_1 applet = new Api_2_Bte_Aptlbss_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //intialise the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer=new byte[(short)(bte_handler.getCapacity()-1)]; + bte_handler.appendArray(buffer,(short)0,(short)(bte_handler.getCapacity()-1)); + //cause Handler Overflow + try{ + bte_handler.appendTLV((byte)0x0D,(short)0,(short)1); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.HANDLER_OVERFLOW){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x02; + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.clear(); + //initialize the handler + bte_handler.appendArray(buffer,(short)0,(short)9); + //-select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-call appendTLV() + bte_handler.appendTLV((byte)0x0E,(short)0,(short)1); + //-verify current TLV + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x03; + //- clear the handler + bte_handler.clear(); + bte_handler.appendTLV((byte)0x84,Util.makeShort((byte)0x00,(byte)0x01),Util.makeShort((byte)0x02,(byte)0x03)); + buffer= new byte[6]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03}; + bte_handler.copy(buffer,(short)0,(short)6); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)6)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x04; + //-succesful call + bte_handler.appendTLV((byte)0x01,Util.makeShort((byte)0xFE,(byte)0xFD),Util.makeShort((byte)0xFC,(byte)0xFB)); + buffer= new byte[12]; + compareBuffer=new byte[]{(byte)0x84,(byte)0x04,(byte)0x00,(byte)01,(byte)0x02,(byte)0x03,(byte)0x01,(byte)0x04,(byte)0xFE,(byte)0xFD,(byte)0xFC,(byte)0xFB}; + //-call copy method + bte_handler.copy(buffer,(short)0,(short)12); + //compare the arrays + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)12)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 5 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x05; + buffer = new byte[247]; + compareBuffer=new byte[253]; + bte_handler.clear(); + buffer[0]=(byte)0x00; + buffer[1]=(byte)0x81; + buffer[2]=(byte)0xF4; + for(short i=3;i<247;i++){ + buffer[3]=(byte)i; + } + Util.arrayCopy(buffer,(short)0,compareBuffer,(short)0,(short)247); + compareBuffer[247]=(byte)0x84; + compareBuffer[248]=(byte)0x04; + compareBuffer[249]=(byte)0x00; + compareBuffer[250]=(byte)0x01; + compareBuffer[251]=(byte)0x02; + compareBuffer[252]=(byte)0x03; + //-call appendArray + bte_handler.appendArray(buffer,(short)0,(short)247); + //-successful call + bte_handler.appendTLV((byte)0x84,Util.makeShort((byte)0x00,(byte)0x01),Util.makeShort((byte)0x02,(byte)0x03)); + //-call getLength() + if(bte_handler.getLength()==(short)253){ + buffer= new byte[253]; + bte_handler.copy(buffer,(short)0,(short)253); + if(Util.arrayCompare(buffer,(short)0,compareBuffer,(short)0,(short)253)==(byte)0x00){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/Test_Api_2_Bte_Aptlbss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/Test_Api_2_Bte_Aptlbss.java new file mode 100644 index 0000000000000000000000000000000000000000..a178ebce5cb31e89063bb2dd51187f6c9306c3c0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/Test_Api_2_Bte_Aptlbss.java @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Aptlbss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_aptlbss; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Aptlbss extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_aptlbss"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Aptlbss(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + //Install package + test.loadPackage(CAP_FILE_PATH); + test.terminalProfileSession("13"); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+ + "05CCCCCC CCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4548b792ba5e1e54fc4b9c139e5605affbca3521 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_aptlbss.Api_2_Bte_Aptlbss_1 +uicc.test.toolkit.api_2_bte_aptlbss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/javacard/api_2_bte_aptlbss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/javacard/api_2_bte_aptlbss.cap new file mode 100644 index 0000000000000000000000000000000000000000..cf3d838a8b4c744bde557ee24fc9a57dfc9e7a96 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_aptlbss/javacard/api_2_bte_aptlbss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/Api_2_Bte_Cler_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/Api_2_Bte_Cler_1.java new file mode 100644 index 0000000000000000000000000000000000000000..4ba0f56f033d421fc598e0cac602ca7942f0f7a7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/Api_2_Bte_Cler_1.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Cler_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_cler; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Cler_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte buffer[] = null; + + /** + * If AID length is not zero register applet with specified AID + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Cler_1 () { + } + /** + * Create an instance of the BaService, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Cler_1 applet = new Api_2_Bte_Cler_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialise the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + buffer=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x00}; + bte_handler.appendArray(buffer,(short)0,(short)9); + //-select Command Details TLV + bte_handler.findTLV((byte)0x81,(byte)0x01); + //-getLength() + if(bte_handler.getLength()>(short)0){ + bte_handler.clear(); + if(bte_handler.getLength()==(short)0){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x02; + try{ + bte_handler.getValueLength(); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/Test_Api_2_Bte_Cler.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/Test_Api_2_Bte_Cler.java new file mode 100644 index 0000000000000000000000000000000000000000..2dc5a3b0049c997ace327cc8beba8708496e70fe --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/Test_Api_2_Bte_Cler.java @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Cler.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_cler; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Cler extends UiccTestModel{ + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_cler"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Cler(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10"+APPLET_AID_1+ + "02CCCC"); + // delete applet and package + test.reset(); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2c1bc0a889a4b30c124eef95e19261eaa330e0fa --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_cler.Api_2_Bte_Cler_1 +uicc.test.toolkit.api_2_bte_cler +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/javacard/api_2_bte_cler.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/javacard/api_2_bte_cler.cap new file mode 100644 index 0000000000000000000000000000000000000000..98faffa474615f35d0cd07908331a6c83692b9b9 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cler/javacard/api_2_bte_cler.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/Api_2_Bte_Copy_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/Api_2_Bte_Copy_1.java new file mode 100644 index 0000000000000000000000000000000000000000..c9ca91baabba15bb66592c8298892e5821387fd1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/Api_2_Bte_Copy_1.java @@ -0,0 +1,239 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Copy_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_copy; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// + +import javacard.framework.ISOException; +import javacard.framework.Util; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +/** + * @author GHartbrod TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates + */ +public class Api_2_Bte_Copy_1 extends TestToolkitApplet { + private byte dstBuffer[] = null; + private byte bArray[]={(byte)0x81, (byte)0x03, (byte)0x01, (byte)0x41, (byte)0x42, (byte)0x82, (byte)0x02, (byte)0x81, (byte)0x43}; + + /** + * If AID length is not zero register applet with specified AID + * + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Copy_1 () { + } + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Copy_1 applet = new Api_2_Bte_Copy_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialise the test applet values + applet.init(); + //initialze byte array with fill value + applet.dstBuffer = new byte[15]; + Util.arrayFillNonAtomic(applet.dstBuffer,(short)0,(short)15,(byte)0xFF); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + /* + * (non-Javadoc) + * + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + boolean bRes=false; + byte testCaseNb=(byte)0x01; + /// allocate a BERTLVEditHandler + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + + bte_handler.setTag((byte)0x01); + //-------------- TESTCASE 1-------------- + //- NULL as parameter to dstBuffer + bte_handler.appendArray(this.bArray,(short)0,(short)9); + try{ + bte_handler.copy(null,(short)0,(short)1); + } + catch(NullPointerException exp){bRes=true;} + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2-------------- + //- dstOffset < dstBuffer + bRes=false; + testCaseNb=(byte)0x02; + try{ + dstBuffer = new byte[5]; + bte_handler.copy(dstBuffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){bRes=true;} + catch(Exception exp){bRes=false;} + + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3-------------- + //- dstOffset < 0 + bRes=false; + testCaseNb=(byte)0x03; + try{ + bte_handler.copy(dstBuffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException exp){bRes=true;} + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4-------------- + //- dstLength > dstBuffer.length + bRes=false; + testCaseNb=(byte)0x04; + try{ + bte_handler.copy(dstBuffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException exp){bRes=true;} + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + + //-------------- TESTCASE 5-------------- + //- dstOffset + dstLength > dstBuffer.length + bRes=false; + testCaseNb=(byte)0x05; + try{ + bte_handler.copy(dstBuffer,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException exp){bRes=true;} + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6-------------- + //- dstLength < 0 + bRes=false; + testCaseNb=(byte)0x06; + try{ + bte_handler.copy(dstBuffer,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){bRes=true;} + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7-------------- + //- dstLength > length of the comprehension TLV list + bRes=false; + testCaseNb=(byte)0x07; + try{ + dstBuffer = new byte[10]; + bte_handler.copy(dstBuffer,(short)0,(short)10); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) bRes=true; + } + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8-------------- + //- successfull call, dstBuffer is the whole bufffer + bRes=false; + testCaseNb=(byte)0x08; + + try{ + dstBuffer = new byte[9]; + if(bte_handler.copy(dstBuffer,(short)0,(short)9)==(short)9){ + bRes=true; + } + } + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9-------------- + //- compare the buffer + bRes=false; + testCaseNb=(byte)0x09; + + if(Util.arrayCompare(dstBuffer,(short)0,bArray,(short)0,(short)9)==(byte)0x00){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10-------------- + //- successfull call, dstBuffer is a part of a buffer + bRes=false; + testCaseNb=(byte)0x0A; + try{ + dstBuffer = new byte[15]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)15,(byte)0xFF); + if(bte_handler.copy(dstBuffer,(short)3,(short)9)==(short)12){ + bRes=true; + } + } + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11-------------- + //- compare the whole buffer + bRes=false; + testCaseNb=(byte)0x0B; + byte compareBuffer[]=new byte[15]; + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)15,(byte)0xFF); + //compare the copied value + if(Util.arrayCompare(dstBuffer,(short)3,bArray,(short)0,(short)9)==(byte)0x00){ + //compare the first part of dstBuffer + if(Util.arrayCompare(dstBuffer,(short)0,compareBuffer,(short)0,(short)3)==(byte)0x00){ + //compare the last part of dstBuffer + if(Util.arrayCompare(dstBuffer,(short)13,compareBuffer,(short)13,(short)2)==(byte)0x00){ + bRes=true; + } + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12-------------- + //- successfull call, dstBuffer is a part of a buffer + bRes=false; + testCaseNb=(byte)0x0C; + try{ + dstBuffer = new byte[15]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)15,(byte)0xFF); + if(bte_handler.copy(dstBuffer,(short)3,(short)6)==(short)9){ + bRes=true; + } + } + catch(Exception exp){bRes=false;} + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13-------------- + //- compare the whole buffer + bRes=false; + testCaseNb=(byte)0x0D; + compareBuffer=new byte[15]; + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)15,(byte)0xFF); + //compare the copied value + if(Util.arrayCompare(dstBuffer,(short)3,bArray,(short)0,(short)6)==(byte)0x00){ + //compare the first part of dstBuffer + if(Util.arrayCompare(dstBuffer,(short)0,compareBuffer,(short)0,(short)3)==(byte)0x00){ + //compare the last part of dstBuffer + if(Util.arrayCompare(dstBuffer,(short)9,compareBuffer,(short)9,(short)6)==(byte)0x00){ + bRes=true; + } + } + } + this.reportTestOutcome(testCaseNb,bRes); + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/Test_Api_2_Bte_Copy.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/Test_Api_2_Bte_Copy.java new file mode 100644 index 0000000000000000000000000000000000000000..b594ee999782ec357454c557299369b0e7d1ef4c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/Test_Api_2_Bte_Copy.java @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Copy.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_copy; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +public class Test_Api_2_Bte_Copy extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_copy"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Copy(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 13 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7bc66502c40be3869814f817e58c8d9ce3e57668 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_copy.Api_2_Bte_Copy_1 +uicc.test.toolkit.api_2_bte_copy +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/javacard/api_2_bte_copy.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/javacard/api_2_bte_copy.cap new file mode 100644 index 0000000000000000000000000000000000000000..1df8c0d9d8ef1cee9d6510f3841926fa211bd7a6 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_copy/javacard/api_2_bte_copy.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/Api_2_Bte_Cprv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/Api_2_Bte_Cprv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ac868b78b795acaa0fdaefbd4342b30f98a66f98 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/Api_2_Bte_Cprv_1.java @@ -0,0 +1,390 @@ +//----------------------------------------------------------------------------- +//Ape_2_Bte_Cprv_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_cprv; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Cprv_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + + /** + */ + private Api_2_Bte_Cprv_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Cprv_1 applet = new Api_2_Bte_Cprv_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialise the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x02}; + bte_handler.appendArray(bArray,(short)0,(short)9); + bte_handler.findTLV((byte)0x81,(byte)0x01);//select TLV structure 0x81 + + //- compareValue() with a null compareBuffer + try{ + bte_handler.compareValue((short)0,null,(short)0,(short)1); + } + catch(NullPointerException exp){ + bRes=true; + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- initialize the handler + try{ + bRes=false; + testCaseNb=(byte)0x02; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{ (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x0F,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0C, + (byte)0x0D,(byte)0x0E}; + + bte_handler.appendArray(bArray,(short)0,(short)bArray.length); + bte_handler.findTLV((byte)0x0D,(byte)0x01); + compareBuffer = new byte[]{(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}; + //- compareOffset>compareBuffer.length + try{ + bte_handler.compareValue((short)0,compareBuffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + //- compareOffset < 0 + try{ + bRes=false; + testCaseNb=0x03; + bte_handler.compareValue((short)0,compareBuffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + //- compareLength>compareBuffer.length + try{ + bRes=false; + testCaseNb=0x04; + bte_handler.compareValue((short)0,compareBuffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + //- compareOffset+compareLength>compareBuffer.length + try{ + bRes=false; + testCaseNb=0x05; + bte_handler.compareValue((short)0,compareBuffer,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6-------------- + //- compareLength<0 + try{ + bRes=false; + testCaseNb=0x06; + bte_handler.compareValue((short)0,compareBuffer,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7-------------- + //- initialize the handler + try{ + bRes=false; + testCaseNb=(byte)0x07; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{ (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x06,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04}; + bte_handler.appendArray(bArray,(short)0, (short)17); + bte_handler.findTLV((byte)0x0D,(byte)0x01); + compareBuffer = new byte[15]; + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)15,(byte)0xFF); + //- valueOffset>Text String Length + try{ + bte_handler.compareValue((short)7,compareBuffer,(short)0,(short)0); + } + catch(ToolkitException exp){ + if(exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8-------------- + //- valueOffset < 0 + try { + bRes = false; + testCaseNb = (byte) 0x08; + bte_handler.findTLV((byte) 0x0D, (byte) 0x01); + try { + bte_handler.compareValue((short) -1, compareBuffer, (short) 0, (short) 1); + } + catch (ToolkitException exp) { + if (exp.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true; + } + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 9-------------- + //- compareLength > Text String Length + try { + bRes = false; + testCaseNb = (byte) 0x09; + bte_handler.findTLV((byte) 0x0D, (byte) 0x01); + try { + bte_handler.compareValue((short) 0, compareBuffer, (short) 0, (short) 7); + } + catch (ToolkitException exp) { + if (exp.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true; + } + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 10-------------- + //- valueOffset + compareLength > Text String Length + try { + bRes = false; + testCaseNb = (byte) 0x0A; + bte_handler.findTLV((byte) 0x0D, (byte) 0x01); + try { + bte_handler.compareValue((short) 2, compareBuffer, (short) 0, (short) 5); + } + catch (ToolkitException exp) { + if (exp.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true; + } + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 11-------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x0B; + bte_handler.clear(); + bte_handler.setTag((byte) 0x01); + bArray = new byte[]{(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x82}; + bte_handler.appendArray(bArray,(short)0, (short)9); + try { + bte_handler.compareValue((short) 0, compareBuffer, (short) 0, (short) 0); + } + catch (ToolkitException exp) { + if (exp.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true; + } + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 12-------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x0C; + bte_handler.clear(); + bte_handler.setTag((byte) 0x01); + bArray = new byte[]{(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x02, + (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, + (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.appendArray(bArray,(short)0, (short)28); + bte_handler.findTLV((byte) 0x0D, (byte) 0x01); + //- initialize compareBuffer + compareBuffer = new byte[]{(byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, + (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + //- compare buffers + if (bte_handler.compareValue((short) 0, compareBuffer, (short) 0, (short) 17)==(byte)0x00){ + bRes=true; + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 13-------------- + //- initialize compare Buffer + try{ + bRes=false; + testCaseNb=(byte)0x0D; + compareBuffer= new byte[]{ (byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x0F,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x10}; + //compare the buffer + if ((short)bte_handler.compareValue((short) 0, compareBuffer, (short) 0, (short) 17)==(short)-1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); +// -------------- TESTCASE 14-------------- + //- initialize compare Buffer + try{ + bRes=false; + testCaseNb=(byte)0x0E; + compareBuffer= new byte[]{ (byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F}; + //compare the buffer + if ((short)bte_handler.compareValue((short) 0, compareBuffer, (short) 0, (short) 17)==(short)1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + + + //-------------- TESTCASE 15-------------- + //- initialize compare Buffer + try{ + bRes=false; + testCaseNb=(byte)0x0F; + compareBuffer= new byte[]{ (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55}; + //compare the buffer + if (bte_handler.compareValue((short) 2, compareBuffer, (short) 3, (short) 12)==(byte)0x00){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 16-------------- + //- initialize compare Buffer + try{ + bRes=false; + testCaseNb=(byte)0x10; + compareBuffer= new byte[]{ (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55}; + //compare the buffer + if ((short)bte_handler.compareValue((short) 2, compareBuffer, (short) 3, (short) 12)==(short)-1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 17-------------- + //- initialize compare Buffer + try{ + bRes=false; + testCaseNb=(byte)0x11; + compareBuffer= new byte[]{ (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0A,(byte)0x0D,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55}; + //compare the buffer + if ((short)bte_handler.compareValue((short) 2, compareBuffer, (short) 3, (short) 12)==(short)1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 18-------------- + //- initialize compare Buffer + try{ + bRes=false; + testCaseNb=(byte)0x12; + compareBuffer= new byte[]{ (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x99,(byte)0x03,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55}; + //compare the buffer + if ((short)bte_handler.compareValue((short) 2, compareBuffer, (short) 3, (short) 12)==(short)1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + } +}//end of class \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/Test_Api_2_Bte_Cprv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/Test_Api_2_Bte_Cprv.java new file mode 100644 index 0000000000000000000000000000000000000000..9263eb58dfe573d1cad3f2b4495fd7fc40ec0fbb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/Test_Api_2_Bte_Cprv.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Cprv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_cprv; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Cprv extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_cprv"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Cprv(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "12CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC " + + "CCCCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + return testresult; + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6ed4a0ead7ae4bdf1cf0a774b415f24a3a039ea9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_cprv.Api_2_Bte_Cprv_1 +uicc.test.toolkit.api_2_bte_cprv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/javacard/api_2_bte_cprv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/javacard/api_2_bte_cprv.cap new file mode 100644 index 0000000000000000000000000000000000000000..e783f54188a1c22342d741b9e8ea335853268b17 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cprv/javacard/api_2_bte_cprv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/Api_2_Bte_Cpyv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/Api_2_Bte_Cpyv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f71e188c9f1bbec8da943e705461db425ef9a546 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/Api_2_Bte_Cpyv_1.java @@ -0,0 +1,328 @@ +//----------------------------------------------------------------------------- +//Ape_2_Bte_Cpyv_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_cpyv; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Cpyv_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + byte dstBuffer[] = null; + + /** + */ + private Api_2_Bte_Cpyv_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Cpyv_1 applet = new Api_2_Bte_Cpyv_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + // + + boolean bRes = false; + + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + try { + bte_handler.setTag((byte) 0x01); + //-------------- TESTCASE 1 -------------- + //- initialize the handler & select a TLV + byte testCaseNb = (byte) 0x01; + bArray = new byte[]{(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82,(byte) 0x02, (byte) 0x81,(byte)0x82}; + bte_handler.appendArray(bArray, (short) 0, (short) 9); + bte_handler.findTLV((byte) 0x81, (byte) 0x01); + //copyValue() with null dstBuffer + try { + bte_handler.copyValue((short)0,null,(short)0,(short)1); + } + catch (NullPointerException exp) { + bRes = true; + } + this.reportTestOutcome(testCaseNb, bRes); + } + catch (Exception exp) { + bRes = false; + this.reportTestOutcome(testCaseNb, bRes); + } + //-------------- TESTCASE 2 -------------- + //- dstOffset > dstBuffer.length + try{ + bRes=false; + testCaseNb=(byte)0x02; + bArray = new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x0D,(byte)0x10,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02, + (byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A, + (byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E}; + bte_handler.clear(); + // - initialize the handler + bte_handler.appendArray(bArray,(short)0,(short)24); + bte_handler.setTag((byte)0x01); + bte_handler.findTLV((byte)0x0D,(byte)0x01); + dstBuffer = new byte[]{(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04}; + //- dstOffset > dstBuffer.length + try{ + bte_handler.copyValue((short)0,dstBuffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 3 -------------- + //-dstOffset < 0 + try{ + bRes=false; + testCaseNb=(byte)0x03; + bte_handler.copyValue((short)0,dstBuffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 4 -------------- + //-dstLength>dstBuffer.length + try{ + bRes=false; + testCaseNb=(byte)0x04; + bte_handler.copyValue((short)0,dstBuffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 5 -------------- + //-dstOffset + dstLength>dstBuffer.length + try{ + bRes=false; + testCaseNb=(byte)0x05; + bte_handler.copyValue((short)0,dstBuffer,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 6 -------------- + //-dstLength < 0 + try{ + bRes=false; + testCaseNb=(byte)0x06; + bte_handler.copyValue((short)0,dstBuffer,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 7 -------------- + //-valueOffset > Text String Length + try{ + bRes=false; + testCaseNb=(byte)0x07; + bArray = new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x06,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04}; + bte_handler.clear(); + // - initialize the handler + bte_handler.appendArray(bArray,(short)0,(short)17); + bte_handler.setTag((byte)0x01); + bte_handler.findTLV((byte)0x0D,(byte)0x01); + dstBuffer = new byte[15]; + for (short i=0; i<(short)15; i++){dstBuffer[i]=(byte)i;} + try{ + bte_handler.copyValue((short)7,dstBuffer,(short)0,(short)0); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 8 -------------- + //- valueOffset < 0 + try{ + bRes=false; + testCaseNb=(byte)0x08; + bte_handler.findTLV((byte)0x0D,(byte)0x01); + bte_handler.copyValue((short)-1,dstBuffer,(short)0,(short)1); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 9 -------------- + //- dstLength> Text String length + try{ + bRes=false; + testCaseNb=(byte)0x09; + bte_handler.findTLV((byte)0x0D,(byte)0x01); + bte_handler.copyValue((short)-1,dstBuffer,(short)0,(short)7); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 10 -------------- + //- valueOffset + dstLength > Text String + try{ + bRes=false; + testCaseNb=(byte)0x0A; + bte_handler.findTLV((byte)0x0D,(byte)0x01); + bte_handler.copyValue((short)2,dstBuffer,(short)0,(short)5); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 11 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0B; + bArray = new byte[]{(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, + (byte) 0x02, (byte) 0x81, (byte) 0x82}; + bte_handler.clear(); + // - initialize the handler + bte_handler.appendArray(bArray, (short) 0, (short) 9); + bte_handler.setTag((byte) 0x01); + try{ + bte_handler.copyValue((short)2,dstBuffer,(short)0,(short)5); + } + catch(ToolkitException exp){ + if (exp.getReason()== ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 12 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0C; + + bArray = new byte[]{(byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.clear(); + // - initialize the handler + bte_handler.appendArray(bArray, (short) 0, (short) 28); + bte_handler.setTag((byte) 0x01); + + + + bte_handler.findTLV((byte) 0x0D, (byte) 0x01); + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 17, (byte) 0x55); + if (bte_handler.copyValue((short) 0, dstBuffer, (short) 0, (short) 17) == (short) 17) { + bRes = true; + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 13 -------------- + //- Compare Buffer + try { + bRes = false; + testCaseNb = (byte) 0x0D; + if (Util.arrayCompare(bArray,(short)11,dstBuffer,(short)0,(short)17)==(byte)0x00){ + bRes=true; + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 14 -------------- + try{ + bRes=false; + testCaseNb=(byte)0x0E; + dstBuffer= new byte[20]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 20, (byte) 0x55); + if(bte_handler.copyValue((short)2,dstBuffer,(short)3,(short)12)==(short) 15){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb, bRes); + //-------------- TESTCASE 15 -------------- + //- compare buffer + try { + bRes = false; + testCaseNb = (byte) 0x0F; + byte compareBuff[] = new byte[]{(byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0x01, + (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, + (byte) 0x09, (byte) 0x0A, (byte) 0x0B, (byte) 0x0C, (byte) 0x55, (byte) 0x55, (byte) 0x55, (byte) 0x55, + (byte) 0x55, (byte) 0x55}; + + if(Util.arrayCompare(compareBuff,(short)0,dstBuffer,(short)0,(short)20)==(byte)0x00){ + bRes=true; + } + + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb, bRes); + + } +} + + + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/Test_Api_2_Bte_Cpyv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/Test_Api_2_Bte_Cpyv.java new file mode 100644 index 0000000000000000000000000000000000000000..4e51734aca7955d222e452faacfc2266973cf28b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/Test_Api_2_Bte_Cpyv.java @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Cpyv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_cpyv; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Cpyv extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_cpyv"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Cpyv(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "0FCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..17c6356db8d6641982e10f7a4efbdebe5a9aad5b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_cpyv.Api_2_Bte_Cpyv_1 +uicc.test.toolkit.api_2_bte_cpyv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/javacard/api_2_bte_cpyv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/javacard/api_2_bte_cpyv.cap new file mode 100644 index 0000000000000000000000000000000000000000..9ddde9414861613728df20a9e0a674f4286e8eec Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_cpyv/javacard/api_2_bte_cpyv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/Api_2_Bte_Facrb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/Api_2_Bte_Facrb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..bea91d0e92888526b978506dc7118223bc8906a6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/Api_2_Bte_Facrb_Bs_1.java @@ -0,0 +1,425 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Facrb_Bs_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facrb_bs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Facrb_Bs_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + * If AID length is not zero register applet with specified AID + * @param bArray the array constaing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray + */ + private Api_2_Bte_Facrb_Bs_1 (byte[] bArray, short bOffset, byte bLength) { + + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Facrb_Bs_1 applet = new Api_2_Bte_Facrb_Bs_1(bArray, bOffset, bLength); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x82}; + bte_handler.appendArray(bArray,(short)0,(short)9); + //- FindAndCopyValue() with a null + try{ + bte_handler.findAndCompareValue((byte)0x81,null,(short)0x00); + } + catch(NullPointerException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x02; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x10, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E }; + bte_handler.appendArray(bArray,(short)0,(short)27); + compareBuffer = new byte[20]; + Util.arrayFillNonAtomic(compareBuffer, (short) 0, (short) 20,(byte) 0xFF); + try{ + bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)21); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + //- compareOfffset < 0 + try { + bRes = false; + testCaseNb = (byte) 0x03; + try{ + bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + //- length> compareBuffer.length + try { + bRes = false; + testCaseNb = (byte) 0x04; + compareBuffer = new byte[15]; + Util.arrayFillNonAtomic(compareBuffer, (short)0, (short)15,(byte)0xFF); + try{ + bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + //- compareOffset + length > compareBuffer + try { + bRes = false; + testCaseNb = (byte) 0x05; + compareBuffer = new byte[20]; + Util.arrayFillNonAtomic(compareBuffer, (short)0, (short)20,(byte)0xFF); + try{ + bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)5); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x06; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F }; + bte_handler.appendArray(bArray,(short)0,(short)28); + //select a tlv tag 0x02 + bte_handler.findTLV((byte)0x02,(byte)0x01); + //find and compare value with tlv tag 0x03 + try{ + bte_handler.findAndCompareValue((byte)0x03,compareBuffer,(short)5); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + try{ + //call the getValueLength() method + bte_handler.getValueLength(); + } + catch(ToolkitException e){ + if (ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7 -------------- + //- initialize the handler + try{ + bRes = false; + testCaseNb = (byte) 0x07; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F }; + bte_handler.appendArray(bArray,(short)0,(short)28); + //- initialize the compareBuffer + compareBuffer = new byte[]{ + (byte)0x04, (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07, (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F}; + //- compare buffers + if(bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)0)==(byte)0x00){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + //- verify current TLV + try{ + bRes = false; + testCaseNb = (byte) 0x08; + if (bte_handler.getValueLength()==(short)17){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x09; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x10}; + //-compare the buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)0)==(short)-1){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0A; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F}; + //-compare the buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)0)==(short)1){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0B; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04, + (byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C, + (byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x55}; + //-compare the buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)2)==(short)0){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0C; + //append a Text String TLV + buffer = new byte[]{(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55}; + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)6); + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04, + (byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C, + (byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x55}; + //-compare the buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)2)==(short)0){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0D; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x04,(byte)0x10,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04, + (byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C, + (byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x55}; + //-compare the buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)2)==(short)-1){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 14 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0E; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04, + (byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C, + (byte)0x0D,(byte)0x0D,(byte)0x10,(byte)0x55}; + //-compare the buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,compareBuffer,(short)2)==(short)1){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 15 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0F; + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F }; + bte_handler.appendArray(bArray,(short)0,(short)28); + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F}; + //-successful call (tag 0x8D) + if((short)bte_handler.findAndCompareValue((byte)0x8D,compareBuffer,(short)0)==(short)0){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 16 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x10; + buffer=new byte[]{ + (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + //-append tag 0x0F + bte_handler.appendTLV((byte)0x0F,buffer,(short)0,(short)16); + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + //-successful call (tag 0x8F) + if((short)bte_handler.findAndCompareValue((byte)0x8F,compareBuffer,(short)0)==(short)0){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 17 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x11; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x00,(byte)0x99,(byte)0x01,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + //-successful call (tag 0x8F) + if((short)bte_handler.findAndCompareValue((byte)0x8F,compareBuffer,(short)0)==(short)1){ + bRes=true; + } + } + catch (Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } + + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/Test_Api_2_Bte_Facrb_Bs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/Test_Api_2_Bte_Facrb_Bs.java new file mode 100644 index 0000000000000000000000000000000000000000..b7b28dad2045a5dbddeb748c61dfbbfac6180001 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/Test_Api_2_Bte_Facrb_Bs.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Facrb_Bs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facrb_bs; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +public class Test_Api_2_Bte_Facrb_Bs extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_facrb_bs"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Facrb_Bs(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "11CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC " + + "CCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..15273b0e8d9fc0c3208fae8f868c5831da9dffbc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_facrb_bs.Api_2_Bte_Facrb_Bs_1 +uicc.test.toolkit.api_2_bte_facrb_bs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/javacard/api_2_bte_facrb_bs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/javacard/api_2_bte_facrb_bs.cap new file mode 100644 index 0000000000000000000000000000000000000000..c697477af5c86349589ea48735535cb3e18e9747 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrb_bs/javacard/api_2_bte_facrb_bs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/Api_2_Bte_Facrbbs_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/Api_2_Bte_Facrbbs_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b54c5a11a40ca53e931712e9c0c3aa43cb354569 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/Api_2_Bte_Facrbbs_Bss_1.java @@ -0,0 +1,568 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Facrbbs_Bss_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facrbbs_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Facrbbs_Bss_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + BERTLVEditHandler bte_handler = null; + byte compareBuffer[] = null; + byte buffer[] = null; + + /** + */ + private Api_2_Bte_Facrbbs_Bss_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Facrbbs_Bss_1 applet = new Api_2_Bte_Facrbbs_Bss_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x82}; + bte_handler.appendArray(bArray,(short)0,(short)9); + compareBuffer = new byte[5]; + //- FindAndCopyValue() with a null compareBuffer + try{ + bte_handler.findAndCompareValue((byte)0x01,(byte)0x01,(short)0,null,(short)0,(short)3); + } + catch(NullPointerException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x02; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x10, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E }; + bte_handler.appendArray(bArray,(short)0,(short)27); + compareBuffer = new byte[5]; + Util.arrayFillNonAtomic(compareBuffer, (short) 0, (short) 5,(byte) 0xFF); + //- compareOffset > compareBufffer.length + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x03; + //-compareOffset < 0 + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x04; + //- compareLength > compareBuffer.length + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x05; + //- compareOffset+compareLength > compareBuffer.length + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x06; + //- compareLength < 0 + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x07; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x06, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04 }; + bte_handler.appendArray(bArray,(short)0,(short)17); + compareBuffer = new byte[15]; + Util.arrayFillNonAtomic(compareBuffer, (short) 0, (short) 15,(byte) 0xFF); + // valueOffset > Text String Length + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)7,compareBuffer,(short)0,(short)0); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x08; + // valueOffst < 0 + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)-1,compareBuffer,(short)0,(short)1); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x09; + // compareLength > Text Strign length + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)7); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0A; + //valueOffset+compareLength > Text String length + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)2,compareBuffer,(short)0,(short)5); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0B; + //- invalid Parameter + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x00,(short)0,compareBuffer,(short)0,(short)5); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.BAD_INPUT_PARAMETER){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0C; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F }; + bte_handler.appendArray(bArray,(short)0,(short)28); + //- select a TLV (tag 0x02) + bte_handler.findTLV((byte)0x02,(byte)0x01); + //- findAndCompareValue + try{ + bte_handler.findAndCompareValue((byte)0x0D,(byte)0x02,(short)0,compareBuffer,(short)0,(short)0); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + try{ + //- Call the getValueLength() method + bte_handler.getValueLength(); + } + catch (ToolkitException e){ + if (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0D; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F }; + bte_handler.appendArray(bArray,(short)0,(short)28); + //-initialize compareBuffer + compareBuffer = new byte[]{ + (byte) 0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte) 0x05, (byte)0x06, + (byte) 0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte) 0x0D,(byte)0x0E, + (byte) 0x0F}; + //- findAndCompareValue + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)17)==(short)0){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 14 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0E; + //-verify current TLV + if(bte_handler.getValueLength()==(short)17){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 15 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x0F; + //- initialize compareBuffer + compareBuffer = new byte[]{ + (byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte) 0x05, (byte)0x06, + (byte) 0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte) 0x0D,(byte)0x0E, + (byte)0x10}; + //- findAndCompareValue + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)17)==(short)-1){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 16 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x10; + //- initialize compareBuffer + compareBuffer = new byte[]{ + (byte)0x03,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte) 0x05, (byte)0x06, + (byte) 0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte) 0x0D,(byte)0x0E, + (byte) 0x0F}; + //- findAndCompareValue + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)17)==(short)1){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 17 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x11; + //- initialize compareBuffer + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55 }; + //- compare buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)2,compareBuffer,(short)3,(short)12)==(short)0){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 18 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x12; + //- initialize compareBuffer + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x02,(byte)0x01,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55 }; + //- compare buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)2,compareBuffer,(short)3,(short)12)==(short)-1){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 19 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x13; + //-initialize the compareBuffer + compareBuffer=new byte[]{ + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05, + (byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0A,(byte)0x0D,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55 }; + //- compare buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)2,compareBuffer,(short)3,(short)12)==(short)1){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 20 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x14; + buffer = new byte[]{(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55}; + //- append a Text String TLV + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)6); + //- initialize compareBuffer + compareBuffer=new byte[]{ + (byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F}; + //- compare buffers + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)17)==(short)0){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 21 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x15; + //- initialize compareBuffer + compareBuffer = new byte[]{(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55}; + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x02,(short)0,compareBuffer,(short)0,(short)6)==(short)0){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 22 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x16; + //- initialize compareBuffer + compareBuffer = new byte[]{(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x66}; + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x02,(short)0,compareBuffer,(short)0,(short)6)==(short)-1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 23 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x17; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F }; + bte_handler.appendArray(bArray,(short)0,(short)28); + //-initialize compareBuffer + compareBuffer = new byte[]{ + (byte) 0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte) 0x05,(byte)0x06, + (byte) 0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte) 0x0D,(byte)0x0E, + (byte) 0x0F}; + //- successful call (with tag 0x8D) + if((short)bte_handler.findAndCompareValue((byte)0x8D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)17)==(short)0){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 24 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x18; + buffer = new byte[]{ + (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + //- append a TLV (tag 0x0F) + bte_handler.appendTLV((byte)0x0F,buffer,(short)0,(short)16); + //- initialize compareBuffer + compareBuffer=new byte[]{ + (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + //- successful call (with tag 0x8F) + if((short)bte_handler.findAndCompareValue((byte)0x8F,(byte)0x01,(short)0,compareBuffer,(short)0,(short)16)==(short)0){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 25 -------------- + try { + bRes = false; + testCaseNb = (byte) 0x19; + //- initialize compareBuffer + compareBuffer=new byte[]{ + (byte)0x04,(byte)0x00,(byte)0x99,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06, + (byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E, + (byte)0x0F}; + if((short)bte_handler.findAndCompareValue((byte)0x0D,(byte)0x01,(short)0,compareBuffer,(short)0,(short)17)==(short)1){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/Test_Api_2_Bte_Facrbbs_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/Test_Api_2_Bte_Facrbbs_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..5b35021617ac80c2d7d7f67ca2e410724029a155 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/Test_Api_2_Bte_Facrbbs_Bss.java @@ -0,0 +1,85 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Facrbbs_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facrbbs_bss; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Facrbbs_Bss extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_facrbbs_bss"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Facrbbs_Bss(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "19CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC " + + "CCCCCCCC CCCCCCCC CCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ec237f97e8029e9d719358da5d3bb074c5d37cfa --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_facrbbs_bss.Api_2_Bte_Facrbbs_Bss_1 +uicc.test.toolkit.api_2_bte_facrbbs_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/javacard/api_2_bte_facrbbs_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/javacard/api_2_bte_facrbbs_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..5aec8db3646f32565560e675edc5fc34f78de292 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facrbbs_bss/javacard/api_2_bte_facrbbs_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/Api_2_Bte_Facyb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/Api_2_Bte_Facyb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e83a1ea231dac5a4c2c7c9b52c2f979dcd222cb3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/Api_2_Bte_Facyb_Bs_1.java @@ -0,0 +1,379 @@ +//----------------------------------------------------------------------------- +//Ape_2_Bte_Facyb_Bs_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facyb_bs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Facyb_Bs_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + BERTLVEditHandler bte_handler = null; + byte dstBuffer[] = null; + + /** + + */ + private Api_2_Bte_Facyb_Bs_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Facyb_Bs_1 applet = new Api_2_Bte_Facyb_Bs_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x02}; + bte_handler.appendArray(bArray,(short)0,(short)9); + //- FindAndCopyValue() with a null dstBuffer + try{ + bte_handler.findAndCopyValue((byte)0x01,null,(byte)0x00); + } + catch(NullPointerException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- initialize the handler + try{ + bRes = false; + testCaseNb = (byte) 0x02; + bArray=new byte[]{ (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x10,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B, + (byte)0x0C,(byte)0x0D,(byte)0x0E}; + + bte_handler.clear(); + bte_handler.appendArray(bArray,(short)0,(short)27); + bte_handler.setTag((byte)0x01); + dstBuffer=new byte[20]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)20,(byte)0xFF); + //-dstOffset>dstBuffer.length + try{ + bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)21); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + //- dstOffst<0 + try{ + bRes = false; + testCaseNb = (byte) 0x03; + + //-dstOffset>dstBuffer.length + try{ + bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + //- length > dstBuffer.length + try{ + bRes = false; + testCaseNb = (byte) 0x04; + dstBuffer = new byte[15]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)15,(byte)0xFF); + //-dstOffset>dstBuffer.length + try{ + bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + //- DstOffset + length > dstBuffer.length + try{ + bRes=false; + testCaseNb=(byte)0x05; + dstBuffer = new byte[20]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)20,(byte)0xFF); + try{ + bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)5); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x06; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x11,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B, + (byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + + bte_handler.appendArray(bArray,(short)0,(short)28); + bte_handler.setTag((byte)0x01); + bte_handler.findTLV((byte)0x02,(byte)0x01); + + try{ + bte_handler.findAndCopyValue((byte)0x03,dstBuffer,(short)0); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + try{ + //call the getValueLength Method + bte_handler.getValueLength(); + } + catch(ToolkitException ex){ + if (ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7 -------------- + //- initialize the handler + try{ + bRes = false; + testCaseNb = (byte) 0x07; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x11,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B, + (byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + + bte_handler.appendArray(bArray,(short)0,(short)28); + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)17,(byte)0xFF); + if(bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)0)==(short)17){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + //-compare buffer + try{ + bRes = true; + testCaseNb =(byte)0x08; + for (short i=0;i<17; i++){ + if (bArray[(short)(11+i)]!=dstBuffer[i]){bRes=false;} + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x09; + dstBuffer = new byte[20]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)20,(byte)0x55); + //-successful call + if (bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)2)==(short)19){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 10 -------------- +// - compare the buffer + try { + bRes = true; + testCaseNb = (byte) 0x0A; + for (short i = 0; i < 17; i++) { + if (bArray[(short)(11 + i)] != dstBuffer[(short)(i + 2)]) { + bRes = false; + } + } + if (dstBuffer[0] != (byte) 0x55 || dstBuffer[1] != (byte) 0x55 || dstBuffer[19] != (byte) 0x55) { + bRes = false; + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0B; + bte_handler.clear(); + bArray = new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.appendArray(bArray, (short) 0, (short) 28); + bte_handler.setTag((byte) 0x01); + //-append a 2nd Text String TLV + bte_handler.appendTLV((byte) 0x0D, (byte) 0xFF); + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 17, (byte) 0x55); + // -successfull call + if(bte_handler.findAndCopyValue((byte)0x0D,dstBuffer,(short)0)==(short)17){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + //-compare the buffer + try { + bRes = true; + testCaseNb = (byte) 0x0C; + for (short i=0;i<17; i++){ + if (bArray[(short)(11+i)]!=dstBuffer[i]){bRes=false;} + } + } + catch (Exception exp) { + bRes = false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13 -------------- + //- initialize the handler + try{ + bRes = false; + testCaseNb = (byte) 0x0D; + bte_handler.clear(); + bArray = new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.appendArray(bArray, (short) 0, (short) 28); + bte_handler.setTag((byte) 0x01); + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 17, (byte) 0x55); + //- successful call (tag 0x8D) + if(bte_handler.findAndCopyValue((byte)0x8D,dstBuffer,(short)0)==(short)17){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 14 -------------- + //- compare the buffer + try{ + bRes = true; + testCaseNb = (byte) 0x0E; + for (short i=0;i<17; i++){ + if (bArray[(short)(11+i)]!=dstBuffer[i]){bRes=false;} + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 15 -------------- + //- append tag (0x0F) + try{ + bRes = false; + testCaseNb = (byte) 0x0F; + dstBuffer = new byte[16]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 16, (byte) 0x55); + byte buffer[]={ + (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + bte_handler.appendTLV((byte)0x0F,buffer,(short)0,(short)16); + if(bte_handler.findAndCopyValue((byte)0x8F,dstBuffer,(short)0)==(short)16){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 16 -------------- + //- compare the buffer + try{ + bRes = true; + testCaseNb = (byte) 0x10; + for (short i=0;i<16; i++){ + if (bArray[(short)(12+i)]!=dstBuffer[i]){bRes=false;} + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/Test_Api_2_Bte_Facyb_Bs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/Test_Api_2_Bte_Facyb_Bs.java new file mode 100644 index 0000000000000000000000000000000000000000..1c11647a79d24303b7317edc982c2873badb96b5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/Test_Api_2_Bte_Facyb_Bs.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Facyb_Bs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facyb_bs; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Facyb_Bs extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_facyb_bs"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Facyb_Bs(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "10CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC " + + "CC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9cc56397f1c32db31ed095826c2fd36047488ce7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_facyb_bs.Api_2_Bte_Facyb_Bs_1 +uicc.test.toolkit.api_2_bte_facyb_bs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/javacard/api_2_bte_facyb_bs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/javacard/api_2_bte_facyb_bs.cap new file mode 100644 index 0000000000000000000000000000000000000000..0673369cc3b55decf4ff0aa06cccacc103024d3b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facyb_bs/javacard/api_2_bte_facyb_bs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/Api_2_Bte_Facybbs_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/Api_2_Bte_Facybbs_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5f7f60544593c2ff21dc0cbebe6f9b4c01f356fd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/Api_2_Bte_Facybbs_Bss_1.java @@ -0,0 +1,504 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Facybbs_Bss_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facybbs_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Facybbs_Bss_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + byte bArray[] = null; + BERTLVEditHandler bte_handler = null; + byte dstBuffer[] = null; + + /** + */ + private Api_2_Bte_Facybbs_Bss_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Facybbs_Bss_1 applet = new Api_2_Bte_Facybbs_Bss_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray= new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x02}; + bte_handler.appendArray(bArray,(short)0,(short)9); + //- FindAndCopyValue() with a null dstBuffer + try{ + bte_handler.findAndCopyValue((byte)0x01,null,(byte)0x00); + } + catch(NullPointerException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //-dstOffset > dstBuffer.length + try{ + bRes = false; + testCaseNb = (byte) 0x02; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x10,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B, + (byte)0x0C,(byte)0x0D,(byte)0x0E}; + bte_handler.appendArray(bArray,(short)0,(short)27); + dstBuffer = new byte[5]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 5, (byte) 0xFF); + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)6,(short)0); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + //-dstOffset > 0 + try{ + bRes = false; + testCaseNb = (byte) 0x03; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)-1,(short)1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + //dstLength>dstBuffer.length + try{ + bRes = false; + testCaseNb = (byte) 0x04; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)0,(short)6); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + //dstOffset+dstBuffer.length + try{ + bRes = false; + testCaseNb = (byte) 0x05; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)3,(short)3); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + //dstLength<0 + try{ + bRes = false; + testCaseNb = (byte) 0x06; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)0,(short)-1); + } + catch(ArrayIndexOutOfBoundsException exp){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x07; + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x06,(byte)0x04,(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03, + (byte)0x04}; + bte_handler.appendArray(bArray,(short)0,(short)17); + dstBuffer = new byte[15]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 15, (byte) 0xFF); + //- valueOffset > Text String Length + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)7,dstBuffer,(short)0,(short)0); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + //- valueOffset < 0 + try{ + bRes = false; + testCaseNb = (byte) 0x08; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)-1,dstBuffer,(short)0,(short)1); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9 -------------- + //- dstLength> Text String Length + try{ + bRes = false; + testCaseNb = (byte) 0x09; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)0,(short)7); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10 -------------- + //- valueOffset + dstLength > Text String length + try{ + bRes = false; + testCaseNb = (byte) 0x0A; + try{ + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)2,dstBuffer,(short)0,(short)5); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11 -------------- + //- valueOffset + dstLength > Text String length + try{ + bRes = false; + testCaseNb = (byte) 0x0B; + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.appendArray(bArray,(short)0,(short)28); + + //- findAndCopyValue() + try{ + bte_handler.findTLV((byte)0x02,(byte)0x01); + bte_handler.findAndCopyValue((byte)0x0D,(byte)0x02,(short)2,dstBuffer,(short)0,(short)0); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + //- call the getValueLength() method + try{ + bte_handler.getValueLength(); + } + catch(ToolkitException tlkexp){ + if(ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x0C; + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.appendArray(bArray,(short)0,(short)28); + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 17, (byte) 0xFF); + if( bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)0,(short)17)==(short)17){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13 -------------- + //- compare buffer + try{ + bRes = true; + testCaseNb = (byte) 0x0D; + for (short i=0;i<17; i++){ + if (bArray[(short)(11+i)]!=dstBuffer[i]){bRes=false;} + } + } + catch(Exception exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 14 -------------- + try{ + bRes=false; + testCaseNb=(byte)0x0E; + //-initialize dstBuffer + dstBuffer = new byte[20]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 20, (byte) 0x55); + //-successful call + if(bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)2,dstBuffer,(short)3,(short)12)==(short)15){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 15 -------------- + //-compare the buffer + try{ + bRes=true; + testCaseNb=(byte)0x0F; + for (short i = 0; i < 12; i++) { + if (bArray[(short)(13 + i)] != dstBuffer[(short)(i + 3)]) { + bRes = false; + } + } + for (short i=0; i<3; i++){ + if(dstBuffer[i]!=(byte)0x55){bRes=false;} + } + for (short i=19; i>14; i--){ + if(dstBuffer[i]!=(byte)0x55){bRes=false;} + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 16 -------------- + try{ + bRes=false; + testCaseNb=(byte)0x10; + byte[] buffer={(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55}; + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 17, (byte) 0xFF); + //-append a text string TLV + bte_handler.appendTLV((byte)0x0D,buffer,(short)0,(short)6); + + //-successful call + if(bte_handler.findAndCopyValue((byte)0x0D,(byte)0x01,(short)0,dstBuffer,(short)0,(short)17)==(short)17){ + bRes=true; + } + + } + catch(Exception exp){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 17 -------------- + //-compare the buffer + try{ + bRes=true; + testCaseNb=(byte)0x11; + for (short i = 0; i < 17; i++) { + if (bArray[(short)(11 + i)] != dstBuffer[(short)(i)]) { + bRes = false; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 18 -------------- + try{ + bRes=false; + testCaseNb=(byte)0x12; + dstBuffer = new byte[6]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 6, (byte) 0xFF); + //-successful call + if(bte_handler.findAndCopyValue((byte)0x0D,(byte)0x02,(short)0,dstBuffer,(short)0,(short)6)==(short)6){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 19 -------------- + //-compare the buffer + try{ + byte[] buffer={(byte)0x00,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0x55}; + bRes=true; + testCaseNb=(byte)0x13; + for (short i = 0; i < 6; i++) { + if (buffer[(short)i] != dstBuffer[(short)(i)]) { + bRes = false; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 20 -------------- + try{ + bRes=false; + testCaseNb=(byte)0x14; + //- initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ + (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x21, (byte) 0x00, (byte) 0x82, (byte) 0x02, (byte) 0x81, + (byte) 0x02, (byte) 0x0D, (byte) 0x11, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, + (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x0B, + (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F}; + bte_handler.appendArray(bArray,(short)0,(short)28); + dstBuffer = new byte[17]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 17, (byte) 0xFF); + if( bte_handler.findAndCopyValue((byte)0x8D,(byte)0x01,(short)0,dstBuffer,(short)0,(short)17)==(short)17){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 21 -------------- + //-compare the buffer + try{ + bRes=true; + testCaseNb=(byte)0x15; + for (short i = 0; i < 17; i++) { + if (bArray[(short)(11 + i)] != dstBuffer[(short)(i)]) { + bRes = false; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 22 -------------- + try{ + bRes=false; + testCaseNb=(byte)0x16; + byte buffer[] = {(byte)0x00,(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07, + (byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F}; + //-append tag 0x0F + bte_handler.appendTLV((byte)0x0F,buffer,(short)0,(short)16); + dstBuffer = new byte[16]; + Util.arrayFillNonAtomic(dstBuffer, (short) 0, (short) 16, (byte) 0xFF); + //-successful call(with tag 0x8F); + if( bte_handler.findAndCopyValue((byte)0x8F,(byte)0x01,(short)0,dstBuffer,(short)0,(short)16)==(short)16){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 23 -------------- + //-compare the buffer + try{ + bRes=true; + testCaseNb=(byte)0x17; + for (short i = 0; i < 16; i++) { + if (bArray[(short)(12 + i)] != dstBuffer[(short)(i)]) { + bRes = false; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } + +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/Test_Api_2_Bte_Facybbs_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/Test_Api_2_Bte_Facybbs_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..4fc013bc731fce6baaa1d0fabf2ab32b098d4ee8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/Test_Api_2_Bte_Facybbs_Bss.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Facybbs_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_facybbs_bss; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Facybbs_Bss extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_facybbs_bss"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Facybbs_Bss(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "17CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7b1a73d398998dfe65047b95325216d9b6ad00c7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_facybbs_bss.Api_2_Bte_Facybbs_Bss_1 +uicc.test.toolkit.api_2_bte_facybbs_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/javacard/api_2_bte_facybbs_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/javacard/api_2_bte_facybbs_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..8423b7c9028f191b47b6d2e5023c82efc1f2491a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_facybbs_bss/javacard/api_2_bte_facybbs_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/Api_2_Bte_Find_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/Api_2_Bte_Find_1.java new file mode 100644 index 0000000000000000000000000000000000000000..974e638a0e0cdeeb126cffb8d5032bd738c58401 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/Api_2_Bte_Find_1.java @@ -0,0 +1,207 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Find_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_find; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// + +import javacard.framework.ISOException; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +/** + * @author ghartbrod + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class Api_2_Bte_Find_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + /** + */ + private Api_2_Bte_Find_1 () { + } + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Find_1 applet = new Api_2_Bte_Find_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short arg0) throws ToolkitException { + byte bArray[]= {(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x83}; + // Result of test + + + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + //-------------- TESTCASE 1-------------- + //- initialize the handler & bad invalid input parameter + testCaseNb= (byte)0x01; + + try{ + bte_handler.appendArray(bArray,(short)0,(short)9); + bte_handler.findTLV((byte)0x81,(byte)0x00); + } + catch(ToolkitException exp){ + if(exp.getReason()==ToolkitException.BAD_INPUT_PARAMETER){ + bRes=true; + } + } + + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2-------------- + //- Search 1st TLV + bRes=false; + testCaseNb=(byte)0x02; + + if(bte_handler.findTLV((byte)0x01,(byte)0x01)==TLV_FOUND_CR_SET){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3-------------- + //- call the getValueLength()method + bRes=false; + testCaseNb=(byte)0x03; + if(bte_handler.getValueLength()==(short)3){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4-------------- + //- Search 2st TLV + bRes=false; + testCaseNb=(byte)0x04; + if(bte_handler.findTLV((byte)0x02,(byte)0x01)==TLV_FOUND_CR_SET){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5-------------- + //- call the getValueLength()method + bRes=false; + testCaseNb=(byte)0x05; + if(bte_handler.getValueLength()==(short)2){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6-------------- + //- Search a wrong tag + bRes=false; + testCaseNb=(byte)0x06; + //select a TLV (tag 02h) + if (bte_handler.findTLV((byte) 0x02, (byte) 0x01) == TLV_FOUND_CR_SET) { + if (bte_handler.findTLV((byte) 0x03, (byte) 0x01) == TLV_NOT_FOUND) { + bRes = true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7-------------- + //- call the getValueLength() method + bRes=false; + testCaseNb=(byte)0x07; + try{ + bte_handler.getValueLength(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8-------------- + //- Search a tag with wrong occurrence + bRes=false; + testCaseNb=(byte)0x08; + if(bte_handler.findTLV((byte)0x01,(byte)0x02)==TLV_NOT_FOUND){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 9-------------- + //- call the getValueLength() method + bRes=false; + testCaseNb=(byte)0x09; + try{ + bte_handler.getValueLength(); + } + catch(ToolkitException exp){ + if (exp.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 10-------------- + //- append a TLV with tag 02h & search it + bRes=false; + testCaseNb=(byte)0x0A; + bte_handler.appendTLV((byte)0x02,(byte)0x00); + if(bte_handler.findTLV((byte)0x02,(byte)0x02)==TLV_FOUND_CR_NOT_SET){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 11-------------- + //- append a TLV with tag 04h & search it + bRes=false; + testCaseNb=(byte)0x0B; + bte_handler.appendTLV((byte)0x04,(byte)0x00); + if(bte_handler.findTLV((byte)0x04,(byte)0x01)==TLV_FOUND_CR_NOT_SET){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 12-------------- + //- Search tag 0x81h + bRes=false; + testCaseNb=(byte)0x0C; + if(bte_handler.findTLV((byte)0x81,(byte)0x01)==TLV_FOUND_CR_SET){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 13-------------- + //- Search tag 0x84h + bRes=false; + testCaseNb=(byte)0x0D; + if(bte_handler.findTLV((byte)0x84,(byte)0x01)==TLV_FOUND_CR_NOT_SET){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + + + + } + + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/Test_Api_2_Bte_Find.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/Test_Api_2_Bte_Find.java new file mode 100644 index 0000000000000000000000000000000000000000..1d34a41061ff20a98102d5c649321b288f93eec1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/Test_Api_2_Bte_Find.java @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Find.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_find; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Find extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_find"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Find(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "0DCCCCCC CCCCCCCC CCCCCC CCCCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5ec371413cce96532ed7900faabfd124fe1dd5d1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_find.Api_2_Bte_Find_1 +uicc.test.toolkit.api_2_bte_find +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/javacard/api_2_bte_find.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/javacard/api_2_bte_find.cap new file mode 100644 index 0000000000000000000000000000000000000000..af3735f5764353973e04a949f1c4a7f5ecd0e9eb Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_find/javacard/api_2_bte_find.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/Api_2_Bte_Gcap_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/Api_2_Bte_Gcap_1.java new file mode 100644 index 0000000000000000000000000000000000000000..79f1f54bfe3e25107dff90a99219fe9074217c85 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/Api_2_Bte_Gcap_1.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Gcap +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gcap; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Gcap_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte buffer[] = null; + + /** + */ + private Api_2_Bte_Gcap_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Gcap_1 applet = new Api_2_Bte_Gcap_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x10); + bte_handler.setTag((byte)0x01); + //- 1.call get Cappacity() + if (bte_handler.getCapacity() == (short) 0x10) { + //- 2.fill the handler + buffer = new byte[0x0E]; + Util.arrayFillNonAtomic(buffer, (short) 0, (short) 0x0E, (byte) 0xFF); + bte_handler.appendTLV((byte) 0x0D, buffer, (short) 0, (short) 0x0E); + //- 3.clear() + bte_handler.clear(); + //- 4. fill the handler with the maximim capacity plus one + try { + buffer = new byte[0x0F]; + Util.arrayFillNonAtomic(buffer, (short) 0, (short) 0x0F, (byte) 0xFF); + bte_handler.appendTLV((byte) 0x0D, buffer, (short) 0, (short) 0x0F); + } + catch (ToolkitException ex) { + if (ex.getReason() == ToolkitException.HANDLER_OVERFLOW) { + bRes = true; + } + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/Test_Api_2_Bte_Gcap.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/Test_Api_2_Bte_Gcap.java new file mode 100644 index 0000000000000000000000000000000000000000..4c859ddc93491593e69d16df2d54b0b426c20ec3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/Test_Api_2_Bte_Gcap.java @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Gcap.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gcap; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Gcap extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_gcap"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Gcap(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + "01CC"); + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b6a9bbeb091a4b94e45d65630644d2f0a3132643 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_gcap.Api_2_Bte_Gcap_1 +uicc.test.toolkit.api_2_bte_gcap +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/javacard/api_2_bte_gcap.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/javacard/api_2_bte_gcap.cap new file mode 100644 index 0000000000000000000000000000000000000000..d481981990da0cdc97028e38c1d04a9632792bf5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gcap/javacard/api_2_bte_gcap.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/Api_2_Bte_Glen_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/Api_2_Bte_Glen_1.java new file mode 100644 index 0000000000000000000000000000000000000000..65efdef552bd48fe250429c84705322fdcfd95dc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/Api_2_Bte_Glen_1.java @@ -0,0 +1,130 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Glen_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_glen; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// + +import javacard.framework.ISOException; +import javacard.framework.Util; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +/** + * @author GHartbrod TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates + */ +public class Api_2_Bte_Glen_1 extends TestToolkitApplet { + private byte bArray[] = new byte[(short)256]; + + /** + */ + private Api_2_Bte_Glen_1 () { + } + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bParam, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Glen_1 applet = new Api_2_Bte_Glen_1(); + byte aidLen = bParam[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bParam, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //initialze byte array with fill value + Util.arrayFillNonAtomic(applet.bArray,(short)0,(short)256,(byte)0xFF); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + /* + * (non-Javadoc) + * + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + boolean bRes=false; + byte testCaseNb=(byte)0x01; + /// allocate a BERTLVEditHandler + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + + bte_handler.setTag((byte)0x01); + //-------------- TESTCASE 1-------------- + //- Clear the handler + bte_handler.clear(); + if (bte_handler.getLength()==(short)0){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2-------------- + //- call the appendArry() method with buffer length 9 + bRes=false; + testCaseNb=(byte)0x02; + bte_handler.appendArray(bArray,(short)0,(short)9); + if (bte_handler.getLength()==(short)9){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3-------------- + //- call the appendArry() method with buffer length 253 + bRes=false; + bte_handler.clear(); + testCaseNb=(byte)0x03; + bte_handler.appendArray(bArray,(short)0,(short)253); + if (bte_handler.getLength()==(short)253){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4-------------- + //- build a 0x7F handler + bRes=false; + testCaseNb=(byte)0x04; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x7F); + bte_handler.appendArray(bArray,(short)0,(short)0x7F); + if (bte_handler.getLength()==(short)0x7F){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5-------------- + //- build a 0x80h handler + bRes=false; + testCaseNb=(byte)0x05; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x80); + bte_handler.appendArray(bArray,(short)0,(short)0x80); + if (bte_handler.getLength()==(short)0x80){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6-------------- + //- build a 0x100h handler + bRes=false; + testCaseNb=(byte)0x06; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.appendArray(bArray,(short)0,(short)0x100); + if (bte_handler.getLength()==(short)0x100){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/Test_Api_2_Bte_Glen.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/Test_Api_2_Bte_Glen.java new file mode 100644 index 0000000000000000000000000000000000000000..bef82dbdf1bc8b685f197c0d49d648aa99365d6b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/Test_Api_2_Bte_Glen.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Glen.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_glen; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Glen extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_glen"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Glen(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession("13"); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("13"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..dac0195e83974b0fbafcfb54fb327c51bf38bb68 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_glen.Api_2_Bte_Glen_1 +uicc.test.toolkit.api_2_bte_glen +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/javacard/api_2_bte_glen.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/javacard/api_2_bte_glen.cap new file mode 100644 index 0000000000000000000000000000000000000000..3722a9599cadbe929ba32e96bd7816d2ce0c5d14 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_glen/javacard/api_2_bte_glen.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/Api_2_Bte_Gtsz_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/Api_2_Bte_Gtsz_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b40d104ff1e7bd6251e254f83ee023f671e6aa6d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/Api_2_Bte_Gtsz_1.java @@ -0,0 +1,135 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Gtsz_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gtsz; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.ToolkitException; + +/** +* Test Area : uicc.toolkit.BERTLVViewHandler.getSize() method +* +* @version 1.0.0 - XX/07/04 +*/ +public class Api_2_Bte_Gtsz_1 extends TestToolkitApplet { + + private byte ba[] = new byte[(short)272]; + + + + /** + */ + private Api_2_Bte_Gtsz_1 () { + } + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Gtsz_1 applet = new Api_2_Bte_Gtsz_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //initialze byte array with fill value + Util.arrayFillNonAtomic(applet.ba,(short)0,(short)272,(byte)0xFF); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + /** + * + * @param event - the type of event to be processed. + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //allocate a BERTLVEditHandler + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x114); + //set BERTag of handler to 0x01 + bte_handler.setTag((byte)0x01); + //-------------- TESTCASE 1-------------- + //- tag 0x01, data length 0x22 + bte_handler.appendArray(ba, (short)0, (short)0x22); + if(bte_handler.getSize()==(short)0x24){ + this.reportTestOutcome((byte)0x01,true); + } + else{ + this.reportTestOutcome((byte)0x01,false); + } + bte_handler.clear(); + //-------------- TESTCASE 2 -------------- + //- tag 0x01, data length 0x7F + bte_handler.appendArray(ba, (short)0, (short)0x7F); + if(bte_handler.getSize()==(short)0x81){ + this.reportTestOutcome((byte)0x02,true); + } + else{ + this.reportTestOutcome((byte)0x02,false); + } + bte_handler.clear(); + //-------------- TESTCASE 3 -------------- + //- tag 0x01, data length 0x80 + bte_handler.appendArray(ba, (short)0, (short)0x80); + if(bte_handler.getSize()==(short)0x83){ + this.reportTestOutcome((byte)0x03,true); + } + else{ + this.reportTestOutcome((byte)0x03,false); + } + bte_handler.clear(); + //-------------- TESTCASE 4 -------------- + //- tag 0x01, data length 0xFF + bte_handler.appendArray(ba, (short)0, (short)0xFF); + if(bte_handler.getSize()==(short)0x102){ + this.reportTestOutcome((byte)0x04,true); + } + else{ + this.reportTestOutcome((byte)0x04,false); + } + bte_handler.clear(); + //-------------- TESTCASE 5 -------------- + //- tag 0x01, data length 0x100 + bte_handler.appendArray(ba,(short)0,(short)0x100); + if(bte_handler.getSize()==(short)0x104){ + this.reportTestOutcome((byte)0x05,true); + } + else{ + this.reportTestOutcome((byte)0x05,false); + } + bte_handler.clear(); + //-------------- TESTCASE 6 -------------- + //- tag 0x01, data length 0x110 + bte_handler.appendArray(ba,(short)0,(short)0x110); + if(bte_handler.getSize()==(short)0x114){ + this.reportTestOutcome((byte)0x06,true); + } + else{ + this.reportTestOutcome((byte)0x06,false); + } + bte_handler.clear(); + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/Test_Api_2_Bte_Gtsz.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/Test_Api_2_Bte_Gtsz.java new file mode 100644 index 0000000000000000000000000000000000000000..1fdd440c0dcb9baf5fef9ee5b6508c77b9612436 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/Test_Api_2_Bte_Gtsz.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Gtsz.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gtsz; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccToolkitService; + +public class Test_Api_2_Bte_Gtsz extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_gtsz"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Gtsz(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "06CCCCCC CCCCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + return testresult; + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..60397ac376578fe1546bb23b20c5373dde327dd6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_gtsz.Api_2_Bte_Gtsz_1 +uicc.test.toolkit.api_2_bte_gtsz +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/javacard/api_2_bte_gtsz.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/javacard/api_2_bte_gtsz.cap new file mode 100644 index 0000000000000000000000000000000000000000..c672f5ae2d42474820e216f5ab9b7413c43ed931 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gtsz/javacard/api_2_bte_gtsz.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/Api_2_Bte_Gvby_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/Api_2_Bte_Gvby_1.java new file mode 100644 index 0000000000000000000000000000000000000000..df067bd593cce6a9651bcafa3f5428df8f430187 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/Api_2_Bte_Gvby_1.java @@ -0,0 +1,198 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Gvby_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gvby; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.ToolkitException; + + + +/** +* Test Area : uicc.toolkit.BERTLVViewHandler.getSize() method +* +* @version 1.0.0 - XX/09/04 +*/ +public class Api_2_Bte_Gvby_1 extends TestToolkitApplet { + + byte bArray[]= {(byte)0x81,(byte)0x03,(byte)0x01,(byte)0xFF,(byte)0xFE,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0xFD}; + + byte baFillValue[]= new byte[240]; + + /** + */ + private Api_2_Bte_Gvby_1 () { + } + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Gvby_1 applet = new Api_2_Bte_Gvby_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * + * @param event - the type of event to be processed. + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //Result of test + boolean bRes = false; + //test case number + byte testCaseNb= (byte)0x01; + + for (short i=0; i<(short)240; i++ ){ + baFillValue[i]=(byte)i; + } + + //allocate a BERTLVEditHandler + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + //set BER Tag 0x01 + bte_handler.setTag((byte)0x01); + + //-------------- TESTCASE 1-------------- + //- initialize the handler + //getValueByte(0) + try{ + bte_handler.appendArray(bArray,(short)0,(short)9); + bte_handler.getValueByte((short)0); + } + catch(ToolkitException exp){ + if(exp.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2-------------- + //- TLV 1, getValuebyte(3) + bRes=false; + testCaseNb=(byte)0x02; + bte_handler.findTLV((byte)0x01,(byte)0x01); + try{ + bte_handler.getValueByte((short)3); + } + catch (ToolkitException exp){ + if (exp.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3-------------- + //- TLV 1, getValueByte(2) + bRes=false; + testCaseNb=(byte)0x03; + bte_handler.findTLV((byte)0x01,(byte)0x01); + if (bte_handler.getValueByte((short)2)==(byte)0xFE){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4-------------- + //- TLV 2, getValueByte(0) + bRes=false; + testCaseNb=(byte)0x04; + bte_handler.findTLV((byte)0x02,(byte)0x01); + if (bte_handler.getValueByte((short)0)==(byte)0x81){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //--------------------------------------- + //prepare the byte array for test case 5 + bArray= new byte[138]; + Util.arrayCopy(new byte[]{(byte)0x81,(byte)0x03,(byte)0x01, + (byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x7F,(byte)0x04},(short)0,bArray,(short)0,(short)12); + Util.arrayCopy(baFillValue,(short)0,bArray,(short)12,(short)126); + //-------------- TESTCASE 5-------------- + //- initialize the handler + bRes=false; + testCaseNb=(byte)0x05; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bte_handler.appendArray(bArray,(short)0,(short)138); + //- TLV 0D, getValueByte(7E) + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if(bte_handler.getValueByte((short)0x7E)==(byte)0x7D){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //--------------------------------------- + //prepare the byte array for test case 6 + bArray= new byte[140]; + Util.arrayCopy(new byte[]{(byte)0x81,(byte)0x03,(byte)0x01, + (byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x81,(byte)0x80,(byte)0x04},(short)0,bArray,(short)0,(short)13); + Util.arrayCopy(baFillValue,(short)0,bArray,(short)13,(short)127); + //-------------- TESTCASE 6-------------- + bRes=false; + testCaseNb=(byte)0x06; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bte_handler.appendArray(bArray,(short)0,(short)140); + //- TLV 0D, getValueByte(7E) + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if (bte_handler.getValueByte((short)0x7E)==(byte)0x7D){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 7-------------- + //getValueByte(0x7F) + bRes=false; + testCaseNb=(byte)0x07; + if (bte_handler.getValueByte((short)0x7F)==(byte)0x7E){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + //--------------------------------------- + //prepare the byte array for test case 8 + bArray= new byte[253]; + Util.arrayCopy(new byte[]{(byte)0x81,(byte)0x03,(byte)0x01, + (byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x81,(byte)0xF1,(byte)0x04},(short)0,bArray,(short)0,(short)13); + Util.arrayCopy(baFillValue,(short)0,bArray,(short)13,(short)240); + //-------------- TESTCASE 8-------------- + //- initialize the handler + bRes=false; + testCaseNb=(byte)0x08; + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bte_handler.appendArray(bArray,(short)0,(short)253); +// - TLV 0D, getValueByte(7E) + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if (bte_handler.getValueByte((short)0xF0)==(byte)0xEF){ + bRes=true; + } + this.reportTestOutcome(testCaseNb,bRes); + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/Test_Api_2_Bte_Gvby.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/Test_Api_2_Bte_Gvby.java new file mode 100644 index 0000000000000000000000000000000000000000..d68e470359999262ce6cb72f82674ac7e6cfbb40 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/Test_Api_2_Bte_Gvby.java @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Gvby.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gvby; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Gvby extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_gvby"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Gvby(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + //Install package + test.loadPackage(CAP_FILE_PATH ); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH , + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope to trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH ); + + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a27dd55b5cdd27e4a3611fc2d80b441fb09ececa --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_gvby.Api_2_Bte_Gvby_1 +uicc.test.toolkit.api_2_bte_gvby +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/javacard/api_2_bte_gvby.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/javacard/api_2_bte_gvby.cap new file mode 100644 index 0000000000000000000000000000000000000000..e6f72d4dc7b33255f2dad2796115dc5fdc6d1c58 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvby/javacard/api_2_bte_gvby.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/Api_2_Bte_Gvle_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/Api_2_Bte_Gvle_1.java new file mode 100644 index 0000000000000000000000000000000000000000..fdc74cc3fb58b50b88de6db5f2e1c00e49253341 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/Api_2_Bte_Gvle_1.java @@ -0,0 +1,190 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Gvle_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gvle; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.ToolkitException; + +/** +* Test Area : uicc.toolkit.BERTLVViewHandler.getSize() method +* +* @version 1.0.0 - XX/07/04 +*/ + +public class Api_2_Bte_Gvle_1 extends TestToolkitApplet { + + + /** + */ + private Api_2_Bte_Gvle_1 () {} + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Gvle_1 applet = new Api_2_Bte_Gvle_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + applet.init(); + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + // TODO Auto-generated method stub + byte bArray[]=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x82}; + // Result of test + boolean bRes = false; + byte testCaseNb= (byte)0x01; + + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + //-------------- TESTCASE 1 -------------- + //- initialize the handler & getValueLength + try{ + bte_handler.appendArray(bArray,(short)0,(short)9); + bte_handler.getValueLength(); + } + catch(ToolkitException exp){ + if(exp.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- Call the appendTLV() method & search 0x0D tag + testCaseNb=(byte)0x02; + bRes=false; + bte_handler.appendTLV((byte)0x0D,bArray,(short)0,(short)0); + try { + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if(bte_handler.getValueLength()==(short)0){ + bRes=true; + } + } + catch (Exception ex) { + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + //- Call the appendTLV() method & search 0x0D tag + testCaseNb=(byte)0x03; + bRes=false; + bArray=new byte[]{(byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x82, + (byte)0x0D,(byte)0x02,(byte)0x04,(byte)0x00}; + bte_handler.clear(); + bte_handler.appendArray(bArray,(short)0,(short)13); + + try { + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if(bte_handler.getValueLength()==(short)0x02){ + bRes=true; + } + } + catch (Exception ex) { + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + //- Call the appendTLV() with tag 0x0D ,length 7F + testCaseNb=(byte)0x04; + bRes=false; + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x82,(byte)0x0D,(byte)0x7F,(byte)0x04}; + byte bFillArray[]=new byte[126]; + Util.arrayFillNonAtomic(bFillArray,(short)0,(short)126,(byte)0x00); + bte_handler.clear(); + bte_handler.appendArray(bArray,(short)0,(short)12); + bte_handler.appendArray(bFillArray,(short)0,(short)126); + try{ + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if(bte_handler.getValueLength()==(short)127){ + bRes=true; + } + } + catch (Exception ex){ + bRes=false; + } + + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + //- Call the appendTLV() with tag 0x0D ,length 0x80 + testCaseNb=(byte)0x05; + bRes=false; + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x82,(byte)0x0D,(byte)0x81,(byte)0x80,(byte)0x04}; + bFillArray=new byte[127]; + Util.arrayFillNonAtomic(bFillArray,(short)0,(short)127,(byte)0x00); + bte_handler.clear(); + bte_handler.appendArray(bArray,(short)0,(short)13); + bte_handler.appendArray(bFillArray,(short)0,(short)127); + try{ + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if(bte_handler.getValueLength()==(short)128){ + bRes=true; + } + } + catch(Exception ex){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 6 -------------- + //- Call the appendTLV() with tag 0x0D ,length F1 + testCaseNb=(byte)0x06; + bRes=false; + bArray=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0x82, + (byte)0x0D,(byte)0x81,(byte)0xF1,(byte)0x04}; + bFillArray=new byte[240]; + Util.arrayFillNonAtomic(bFillArray,(short)0,(short)240,(byte)0x00); + bte_handler.clear(); + bte_handler.appendArray(bArray,(short)0,(short)13); + bte_handler.appendArray(bFillArray,(short)0,(short)240); + try{ + bte_handler.findTLV((byte)0x0D,(byte)0x01); + if(bte_handler.getValueLength()==(short)241){ + bRes=true; + } + } + catch(Exception ex){ + bRes=false; + } + + this.reportTestOutcome(testCaseNb,bRes); + + + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/Test_Api_2_Bte_Gvle.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/Test_Api_2_Bte_Gvle.java new file mode 100644 index 0000000000000000000000000000000000000000..2955e20a117869cb0e7fed62cfbcbd19a01e63f8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/Test_Api_2_Bte_Gvle.java @@ -0,0 +1,79 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Gvle.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gvle; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Gvle extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_gvle"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Gvle(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" ); // V Maximum number of services + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "06CCCCCC CCCCCC"); + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..20d8a0e619f87194a6e0b6334ec180578b611aa6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_gvle.Api_2_Bte_Gvle_1 +uicc.test.toolkit.api_2_bte_gvle +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/javacard/api_2_bte_gvle.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/javacard/api_2_bte_gvle.cap new file mode 100644 index 0000000000000000000000000000000000000000..890b8adf94ae0f0a58b022fe392c7174a82f69ea Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvle/javacard/api_2_bte_gvle.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/Api_2_Bte_Gvsh_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/Api_2_Bte_Gvsh_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1cee10ad4494a80cff825a04155515499efb5b9c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/Api_2_Bte_Gvsh_1.java @@ -0,0 +1,229 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Gvsh_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gvsh; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.BERTLVEditHandler; +import uicc.toolkit.ToolkitException; + +public class Api_2_Bte_Gvsh_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 0x00; + BERTLVEditHandler bte_handler = null; + byte bArray[] = null; + + /** + */ + private Api_2_Bte_Gvsh_1 () { + } + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Gvsh_1 applet = new Api_2_Bte_Gvsh_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + //initialize the test applet values + applet.init(); + //register applet to event + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /* (non-Javadoc) + * @see uicc.toolkit.ToolkitInterface#processToolkit(short) + */ + public void processToolkit(short event) throws ToolkitException { + //-------------- TESTCASE 1 -------------- + //- initialize the handler + try { + bRes = false; + testCaseNb = (byte) 0x01; + bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x100); + bte_handler.setTag((byte)0x01); + bArray=new byte[]{ (byte)0x81,(byte)0x03,(byte)0x01,(byte)0xFF,(byte)0xFE,(byte)0x82,(byte)0x02,(byte)0x81,(byte)0xFD}; + //-initialize the handler. + bte_handler.appendArray(bArray,(short)0,(short)9); + try{ + bte_handler.getValueShort((short)0); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.UNAVAILABLE_ELEMENT){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 2 -------------- + //- search TLV 0x01 (command details TLV) + try{ + bRes = false; + testCaseNb = (byte) 0x02; + bte_handler.findTLV((byte)0x01,(byte)0x1); + try{ + bte_handler.getValueShort((short)3); + } + catch(ToolkitException ex){ + if(ex.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES){ + bRes=true; + } + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 3 -------------- + //- search TLV 0x01 (command details TLV) + try{ + bRes = false; + testCaseNb = (byte) 0x03; + bte_handler.findTLV((byte)0x01,(byte)0x1); + if(bte_handler.getValueShort((short)1)==(short)0xFFFE){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 4 -------------- + //- search TLV 0x02 (Device Identities TLV) + try{ + bRes = false; + testCaseNb = (byte) 0x04; + bte_handler.findTLV((byte)0x02,(byte)0x1); + if(bte_handler.getValueShort((short)0)==(short)0x81FD){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 5 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x05; + bArray =new byte[138]; + byte temp[]=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x7F,(byte)0x04}; + for (short i=0; i<12;i++){ + bArray[i]=temp[i]; + } + for (short i=0; i<126;i++){ + bArray[(short)(i+12)]=(byte)i; + } + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bte_handler.appendArray(bArray,(short)0,(short)138); + //-search TLV 0x0D (Text String TLV) + bte_handler.findTLV((byte)0x0D,(byte)0x1); + if(bte_handler.getValueShort((short)0x7D)==(short)0x7C7D){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 6 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x06; + bArray =new byte[140]; + byte temp[]=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x81,(byte)0x80,(byte)0x04}; + for (short i=0; i<13;i++){ + bArray[i]=temp[i]; + } + for (short i=0; i<127;i++){ + bArray[(short)(i+13)]=(byte)i; + } + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bte_handler.appendArray(bArray,(short)0,(short)140); + //-search TLV 0x0D (Text String TLV) + bte_handler.findTLV((byte)0x0D,(byte)0x1); + if(bte_handler.getValueShort((short)0x7D)==(short)0x7C7D){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); +// -------------- TESTCASE 7 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x07; + if(bte_handler.getValueShort((short)0x7E)==(short)0x7D7E){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + //-------------- TESTCASE 8 -------------- + try{ + bRes = false; + testCaseNb = (byte) 0x08; + bArray =new byte[253]; + byte temp[]=new byte[]{ + (byte)0x81,(byte)0x03,(byte)0x01,(byte)0x21,(byte)0x00,(byte)0x82,(byte)0x02,(byte)0x81, + (byte)0x02,(byte)0x0D,(byte)0x81,(byte)0xF1,(byte)0x04}; + for (short i=0; i<13;i++){ + bArray[i]=temp[i]; + } + for (short i=0; i<240;i++){ + bArray[(short)(i+13)]=(byte)i; + } + //-initialize the handler + bte_handler.clear(); + bte_handler.setTag((byte)0x01); + bte_handler.appendArray(bArray,(short)0,(short)253); + //-search TLV 0x0D (Text String TLV) + bte_handler.findTLV((byte)0x0D,(byte)0x1); + if(bte_handler.getValueShort((short)0xEF)==(short)0xEEEF){ + bRes=true; + } + } + catch(Exception exp){ + bRes=false; + } + this.reportTestOutcome(testCaseNb,bRes); + + + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/Test_Api_2_Bte_Gvsh.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/Test_Api_2_Bte_Gvsh.java new file mode 100644 index 0000000000000000000000000000000000000000..645c30ac24ab47453118450d0ded2d42f2ef4cc8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/Test_Api_2_Bte_Gvsh.java @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Gvsh.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_gvsh; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Gvsh extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_gvsh"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Gvsh(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run(){ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + //Install package + test.loadPackage(CAP_FILE_PATH); + //install applet 1 + response = test.installApplet( + CAP_FILE_PATH, + CLASS_AID_1, + APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + ); + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" +APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..849f5b1f15b162176d1fb110e451e911df50d682 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_gvsh.Api_2_Bte_Gvsh_1 +uicc.test.toolkit.api_2_bte_gvsh +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/javacard/api_2_bte_gvsh.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/javacard/api_2_bte_gvsh.cap new file mode 100644 index 0000000000000000000000000000000000000000..2644e4383d5176a577c6b63205f69877b1ac25b7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_gvsh/javacard/api_2_bte_gvsh.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/Api_2_Bte_Sttg_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/Api_2_Bte_Sttg_1.java new file mode 100644 index 0000000000000000000000000000000000000000..72214e97a7b083912c6979892111f6192bad5d6a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/Api_2_Bte_Sttg_1.java @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +//Api_2_Bte_Sttg_1 +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_sttg; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +// +import javacard.framework.*; +import uicc.toolkit.*; +import uicc.system.HandlerBuilder; +import uicc.test.util.TestToolkitApplet; + +/** + * Test Area : uicc.toolkit.BERTLVEditHandler.setTag(byte bBERTag) method + * + * @version 1.0.0 - XX/07/04 + */ +public class Api_2_Bte_Sttg_1 extends TestToolkitApplet { + + /** + */ + private Api_2_Bte_Sttg_1 () { + + } + + /** + * Create an instance of the applet, the Java Card runtime environment will call this static method first. + * + * @param bArray the array containing installation parameters + * @param bOffset the starting offset in bArray + * @param bLength the length in bytes of the parameter data in bArray The maximum value of bLength is 127. + * @throws ISOException if the install method failed + * @see javacard.framework.Applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { + Api_2_Bte_Sttg_1 applet = new Api_2_Bte_Sttg_1(); + byte aidLen = bArray[bOffset]; + if (aidLen == (byte) 0) { + applet.register(); + } + else { + applet.register(bArray, (short) (bOffset + 1), aidLen); + } + applet.init(); + applet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + /* + * // Get the system instance of the EnvelopeHandler class + */ + public void processToolkit(short event) throws ToolkitException { + + try { + //allocate a BERTLVEditHandler + BERTLVEditHandler bte_handler = (BERTLVEditHandler) HandlerBuilder.buildTLVHandler(HandlerBuilder.BER_EDIT_HANDLER, (short) 0x10); + //Test Case 1 + bte_handler.setTag((byte) 0x01); + if (bte_handler.getTag() == (byte) 0x01) { + this.reportTestOutcome((byte) 0x01, true); + } + else { + this.reportTestOutcome((byte) 0x01, false);//test failed + } + } + catch (SystemException sysexp) { + this.reportTestOutcome((byte) 0x01, false);//test failed + } + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/Test_Api_2_Bte_Sttg.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/Test_Api_2_Bte_Sttg.java new file mode 100644 index 0000000000000000000000000000000000000000..a2692edc3fcec2e1b2ed3cc2770452a6ba1403b0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/Test_Api_2_Bte_Sttg.java @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Bte_Sttg.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_bte_sttg; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +public class Test_Api_2_Bte_Sttg extends UiccTestModel { + /** relative path of the package */ + private static String CAP_FILE_PATH = "uicc/test/toolkit/api_2_bte_sttg"; + /** test applet 1 class AID */ + private static String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + /** test applet 1 instance aid */ + private static String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + /** */ + private static String TERMINAL_PROFILE = "09030120 00000000 00000000 FF"; + /** */ + private UiccAPITestCardService test = null; + /** contains the response from the executed command */ + private APDUResponse response = null; + /** stores the test result */ + private boolean testresult = false; + + /** + * + */ + public Test_Api_2_Bte_Sttg(){ + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + /** + * Installs the applet, runs the tests and checks the test result. + */ + public boolean run() { + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // Install package + test.loadPackage(CAP_FILE_PATH); + // install applet 1 + response = test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" // V Maximum number of services + ); + + test.reset(); + test.terminalProfileSession(TERMINAL_PROFILE); + // unrecognizeEnvelope trigger test case 1 to 12 of applet 1 + test.unrecognizedEnvelope(); + // check test results + response = test.selectApplication(APPLET_AID_1); + testresult = response.checkData("10" + APPLET_AID_1 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return testresult; + } + + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..be3d95291d40a047abc50dc2499b015c20e54923 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_bte_sttg.Api_2_Bte_Sttg_1 +uicc.test.toolkit.api_2_bte_sttg +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/javacard/api_2_bte_sttg.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/javacard/api_2_bte_sttg.cap new file mode 100644 index 0000000000000000000000000000000000000000..ba021c74acf4975979537b5d886fc311ebb7edce Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_bte_sttg/javacard/api_2_bte_sttg.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/Api_2_Ehs_Gthd_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/Api_2_Ehs_Gthd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d439d3c7e59f011222fc2fa297885ad21e02fc81 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/Api_2_Ehs_Gthd_1.java @@ -0,0 +1,126 @@ +//----------------------------------------------------------------------------- +//Api_2_Ehs_Gthd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_ehs_gthd; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.EnvelopeHandler; +import uicc.toolkit.EnvelopeHandlerSystem; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_ehs_gthd + * + * @version 0.0.1 - 2 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Ehs_Gthd_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + + /** + * Constructor of the applet + */ + public Api_2_Ehs_Gthd_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Ehs_Gthd_1 thisApplet = new Api_2_Ehs_Gthd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : use th methode getTheHandler() Twice + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + EnvelopeHandler EnvHdlr1 = EnvelopeHandlerSystem.getTheHandler(); + EnvelopeHandler EnvHdlr2 = EnvelopeHandlerSystem.getTheHandler(); + + if (EnvHdlr1==EnvHdlr2 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : verify that the methode getTheHandler return EnvelopeHandler reference + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + EnvelopeHandler EnvHdlr1 = EnvelopeHandlerSystem.getTheHandler(); + + if (EnvHdlr1 instanceof EnvelopeHandler) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : verify that the methode getTheHandler does not return NULL + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + EnvelopeHandler EnvHdlr1 = EnvelopeHandlerSystem.getTheHandler(); + + if (EnvHdlr1!=null) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } +} + + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/Test_Api_2_Ehs_Gthd.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/Test_Api_2_Ehs_Gthd.java new file mode 100644 index 0000000000000000000000000000000000000000..c3495e2b4732eda3593796c3928e7f92c01b3427 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/Test_Api_2_Ehs_Gthd.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Ehs_Gthd.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_ehs_gthd; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_ehs_gthd + * + * @version 0.0.1 - 2 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Ehs_Gthd extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_ehs_gthd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Ehs_Gthd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Applet installation */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 3 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test cases 1,2,3 + for (byte i = 0; i< 3; i++) + { + response = test.unrecognizedEnvelope(); + } + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "03CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7906963567ed6a823508e722ff17da377057ea30 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_ehs_gthd.Api_2_Ehs_Gthd_1 +uicc.test.toolkit.api_2_ehs_gthd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/javacard/api_2_ehs_gthd.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/javacard/api_2_ehs_gthd.cap new file mode 100644 index 0000000000000000000000000000000000000000..bfb864f1a8f9bb5e7f6ad8721938a5172163fd94 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ehs_gthd/javacard/api_2_ehs_gthd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/Api_2_Enh_Copy_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/Api_2_Enh_Copy_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d6e55da2b963f90f625d1bc13793e5f501d33855 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/Api_2_Enh_Copy_1.java @@ -0,0 +1,468 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Copy_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_copy; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_enh_copy + * + * @version 0.0.1 - 2 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Copy_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + private byte[] CmpBuffer = {(byte)0x82,(byte)0x02,(byte)0x83,(byte)0x81, + (byte)0x02,(byte)0x29, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09}; + + private byte[] CmpBuffer2 = {(byte)0x00 ,(byte)0x00 ,(byte)0x00 , + (byte)0x82,(byte)0x02,(byte)0x83,(byte)0x81, + (byte)0x02,(byte)0x29, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09}; + + private byte[] CmpBuffer3 = {(byte)0x00 ,(byte)0x00 ,(byte)0x00 , + (byte)0x82,(byte)0x02,(byte)0x83,(byte)0x81, + (byte)0x02,(byte)0x81,(byte)0xF5, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05}; + + private byte[] CmpBuffer4 = {(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x82,(byte)0x02,(byte)0x83}; + + private byte[] dstBuffer; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Copy_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Copy_1 thisApplet = new Api_2_Enh_Copy_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : the destination buffer is null + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + envHdlr.copy(null,(short)0,envHdlr.getLength()); + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : the destination offset is > to the buffer length + testCaseNb = (byte) 2 ; + + dstBuffer = new byte[5]; + bRes = false ; + try { + envHdlr.copy(dstBuffer,(short)5,(short)1); + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : the destination offset is <0 + testCaseNb = (byte) 3 ; + + dstBuffer = new byte[5]; + bRes = false ; + try { + envHdlr.copy(dstBuffer,(short)(-1),(short)1); + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : the destination length is bigger to the buffer length + testCaseNb = (byte) 4 ; + + dstBuffer = new byte[5]; + bRes = false ; + try { + envHdlr.copy(dstBuffer,(short)0,(short)6); + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : the destination offset + length is bigger than the buffer length + testCaseNb = (byte) 5 ; + + dstBuffer = new byte[5]; + bRes = false ; + try { + envHdlr.copy(dstBuffer,(short)3,(short)3); + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : the destination length is <0 + testCaseNb = (byte) 6 ; + + dstBuffer = new byte[5]; + bRes = false ; + try { + envHdlr.copy(dstBuffer,(short)0,(short)(-1)); + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : the destination length is > TLV length + testCaseNb = (byte) 7 ; + + dstBuffer = new byte[48]; + bRes = false ; + try { + envHdlr.copy(dstBuffer,(short)0,(short)dstBuffer.length); + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : + testCaseNb = (byte) 8 ; + + dstBuffer = new byte[47]; + bRes = false ; + try { + if(envHdlr.copy(dstBuffer,(short)0,(short)47)==0x002F) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : compare the buffer + testCaseNb = (byte) 9 ; + + dstBuffer = new byte[47]; + bRes = false ; + try { + if((envHdlr.copy(dstBuffer,(short)0,(short)47)==0x002F) + &&(Util.arrayCompare(dstBuffer,(short)0,CmpBuffer,(short)0,(short)CmpBuffer.length))==0) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : copy in a part of the buffer + testCaseNb = (byte) 10 ; + + dstBuffer = new byte[50]; + bRes = false ; + try { + if(envHdlr.copy(dstBuffer,(short)3,(short)47)==0x0032) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : compare the whole buffer + testCaseNb = (byte) 11 ; + + dstBuffer = new byte[50]; + bRes = false ; + try { + if((envHdlr.copy(dstBuffer,(short)3,(short)47)==0x0032) + &&(Util.arrayCompare(dstBuffer,(short)0,CmpBuffer2,(short)0,(short)CmpBuffer2.length))==0) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + case (byte) 11 : + // -------------------------------------------- + // Test Case 12 : copy in a part of the buffer + testCaseNb = (byte) 12 ; + + dstBuffer = new byte[252]; + bRes = false ; + try { + if(envHdlr.copy(dstBuffer,(short)0,(short)dstBuffer.length)==0x00FC) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 12 : + // -------------------------------------------- + // Test Case 13 : compare the whole buffer + testCaseNb = (byte) 13 ; + + dstBuffer = new byte[255]; + bRes = false ; + try { + if((envHdlr.copy(dstBuffer,(short)3,(short)252)==0x00FF) + &&(Util.arrayCompare(dstBuffer,(short)0,CmpBuffer3,(short)0,(short)CmpBuffer3.length))==0) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 13 : + // -------------------------------------------- + // Test Case 14 : copy in a part of the buffer + testCaseNb = (byte) 14 ; + + dstBuffer = new byte[260]; + bRes = false ; + try { + if(envHdlr.copy(dstBuffer,(short)257,(short)3)==0x0104) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 15 : compare the whole buffer + testCaseNb = (byte) 15 ; + + dstBuffer = new byte[260]; + bRes = false ; + try { + if((envHdlr.copy(dstBuffer,(short)257,(short)3)==0x0104) + &&(Util.arrayCompare(dstBuffer,(short)0,CmpBuffer4,(short)0,(short)CmpBuffer4.length))==0) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 15 : + // -------------------------------------------- + // Test Case 16 : successful call with the length=0 and the offset = length of the destination buffer + testCaseNb = (byte) 16 ; + + bRes = false ; + try { + if(envHdlr.copy(dstBuffer,(short)dstBuffer.length,(short)0)==dstBuffer.length) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + default : + break; + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/Test_Api_2_Enh_Copy.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/Test_Api_2_Enh_Copy.java new file mode 100644 index 0000000000000000000000000000000000000000..bb7fd34f456d4f08faad38670b3ec3a6dcc2cdf7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/Test_Api_2_Enh_Copy.java @@ -0,0 +1,273 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Copy_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_copy; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_enh_copy + * + * @version 0.0.1 - 2 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Copy extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_copy"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Copy() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test cases 1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("90 00"); + + // Test cases 1 to 7 + for(byte i = 1; i < 7; i++) + { + // 1: Send Unrecognized Envelope + response = test.unrecognizedEnvelope(); + result &= response.checkSw("90 00"); + } + + // Test case 8 + // Send Unrecognized Envelope with BER TLV length set to 47 + response = test.sendApdu( "80 C2 00 00 31" + + "01 2F" + + "82 02 83 81" + + "02 29" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 09"); + + // Test case 9 + // Send Unrecognized Envelope with BER TLV length set to 47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 31" + + "01 2F" + + "82 02 83 81" + + "02 29" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 09"); + + // Test case 10 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 31" + + "01 2F" + + "82 02 83 81" + + "02 29" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 09"); + + // Test case 11 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 31" + + "01 2F" + + "82 02 83 81" + + "02 29" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 09"); + + // Test case 12 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "02 81 F5" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05"); + + // Test case 13 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "02 81 F5" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05"); + + // Test case 14 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "02 81 F5" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05"); + + // Test case 15 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "02 81 F5" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05"); + + // Test case 16 + // Send Unrecognized Envelope with BER TLV set to 0x47 and compare the buffer + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "02 81 F5" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "10CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..45a7bd9f72d9774131f896355c75fab0aef788fd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_copy.Api_2_Enh_Copy_1 +uicc.test.toolkit.api_2_enh_copy +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/javacard/api_2_enh_copy.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/javacard/api_2_enh_copy.cap new file mode 100644 index 0000000000000000000000000000000000000000..ea6058d506bd96c68ca3085fa85b40add00dbde0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_copy/javacard/api_2_enh_copy.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/Api_2_Enh_Cprv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/Api_2_Enh_Cprv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..fdf515a4e89b2e4f1812669bf6f97ca42602cbe8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/Api_2_Enh_Cprv_1.java @@ -0,0 +1,519 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Cprv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_cprv; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Cprv + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Cprv_1 extends TestToolkitApplet +{ + + + private byte[] compBuffer; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Cprv_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Cprv_1 thisApplet = new Api_2_Enh_Cprv_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the compareValue method with a null compare Buffer + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.compareValue((short)0,null,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the compareValue method with an offset > buffer length + testCaseNb = (byte) 2 ; + + bRes = false ; + compBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x0B,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)5,(short)1)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the compareValue method with an offset = -1 + testCaseNb = (byte) 3 ; + + bRes = false ; + compBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x0B,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)-1,(short)1)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the compareValue method with an length > buffer length + testCaseNb = (byte) 4 ; + + bRes = false ; + compBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x0B,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)0,(short)6)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : use the compareValue method with an Offset + length > buffer length + testCaseNb = (byte) 5 ; + + bRes = false ; + compBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x0B,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)3,(short)3)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the compareValue method with an compare length < 0 + testCaseNb = (byte) 6 ; + + bRes = false ; + compBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x0B,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)0,(short)-1)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : use the compareValue method with ValueOffset > TLV length + testCaseNb = (byte) 7 ; + + bRes = false ; + compBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)6,compBuffer,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : use the compareValue method with ValueOffset <0 + testCaseNb = (byte) 8 ; + + bRes = false ; + compBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)-1,compBuffer,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : use the compareValue method with dstlength > TLV length + testCaseNb = (byte) 9 ; + + bRes = false ; + compBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)0,(short)7)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : use the compareValue method with ValueOffset+dstlength > TLV length + testCaseNb = (byte) 10 ; + + bRes = false ; + compBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)2,compBuffer,(short)0,(short)5)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : use the compareValue method without current TVL + testCaseNb = (byte) 11 ; + + bRes = false ; + compBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x01,(byte)1)==TLV_NOT_FOUND) + &&(envHdlr.compareValue((short)2,compBuffer,(short)0,(short)5)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 11 : + // -------------------------------------------- + // Test Case 12 : use the compareValue method (normal execution comparaison buffer = TLV) + testCaseNb = (byte) 12 ; + + bRes = false ; + compBuffer =new byte[6]; + + //intialize the array + compBuffer [0]= (byte)0x81; + compBuffer [1]= (byte)0x11; + compBuffer [2]= (byte)0x22; + compBuffer [3]= (byte)0x33; + compBuffer [4]= (byte)0x44; + compBuffer [5]= (byte)0xF5; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)0,(short)6)==0)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 12 : + // -------------------------------------------- + // Test Case 13 : use the compareValue method (normal execution comparaison buffer > TLV) + testCaseNb = (byte) 13 ; + + bRes = false ; + compBuffer =new byte[6]; + + //intialize the array + compBuffer [0]= (byte)0x80; + compBuffer [1]= (byte)0x11; + compBuffer [2]= (byte)0x22; + compBuffer [3]= (byte)0x33; + compBuffer [4]= (byte)0x44; + compBuffer [5]= (byte)0xF5; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)0,(short)6)==1)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 13 : + // -------------------------------------------- + // Test Case 14 : use the compareValue method (normal execution comparaison buffer < TLV) + testCaseNb = (byte) 14 ; + + bRes = false ; + + //intialize the array + compBuffer [0]= (byte)0x83; + compBuffer [1]= (byte)0x11; + compBuffer [2]= (byte)0x22; + compBuffer [3]= (byte)0x33; + compBuffer [4]= (byte)0x44; + compBuffer [5]= (byte)0xF5; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)0,compBuffer,(short)0,(short)6)==-1)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 15 : use the compareValue method with differents parameters(normal execution comparaison buffer = TLV) + testCaseNb = (byte) 15 ; + + bRes = false ; + compBuffer =new byte[13]; + + //intialize the array + for(byte i=0;i<13;i++) + compBuffer[i]=(byte)0x55; + + compBuffer [3]= (byte)0x81; + compBuffer [4]= (byte)0x11; + compBuffer [5]= (byte)0x22; + compBuffer [6]= (byte)0x33; + compBuffer [7]= (byte)0x44; + compBuffer [8]= (byte)0xF5; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)1,compBuffer,(short)4,(short)5)==0)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 15 : + // -------------------------------------------- + // Test Case 16 : use the compareValue method with differents parameters(normal execution comparaison buffer > TLV) + testCaseNb = (byte) 16 ; + + bRes = false ; + compBuffer =new byte[13]; + + //intialize the array + for(byte i=0;i<13;i++) + compBuffer[i]=(byte)0x55; + + compBuffer [3]= (byte)0x81; + compBuffer [4]= (byte)0x10; + compBuffer [5]= (byte)0x23; + compBuffer [6]= (byte)0x33; + compBuffer [7]= (byte)0x44; + compBuffer [8]= (byte)0xF5; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)1,compBuffer,(short)4,(short)5)==+1)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 16 : + // -------------------------------------------- + // Test Case 17 : use the compareValue method with differents parameters(normal execution comparaison buffer < TLV) + testCaseNb = (byte) 17 ; + + bRes = false ; + compBuffer =new byte[13]; + + //intialize the array + for(byte i=0;i<13;i++) + compBuffer[i]=(byte)0x55; + + compBuffer [3]= (byte)0x81; + compBuffer [4]= (byte)0x12; + compBuffer [5]= (byte)0x21; + compBuffer [6]= (byte)0x33; + compBuffer [7]= (byte)0x44; + compBuffer [8]= (byte)0xF5; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)1,compBuffer,(short)4,(short)5)==-1)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 17 : + // -------------------------------------------- + // Test Case 18 : use successfully the compareValue method with the length of the copy =0 + testCaseNb = (byte) 18 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.compareValue((short)1,compBuffer,(short)compBuffer.length,(short)0)==0)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/Test_Api_2_Enh_Cprv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/Test_Api_2_Enh_Cprv.java new file mode 100644 index 0000000000000000000000000000000000000000..ea43f35fdb0f0ebd0a0f2b0d9aeb12e5ba6b2c73 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/Test_Api_2_Enh_Cprv.java @@ -0,0 +1,120 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Cprv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_cprv; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.api_2_enh_cprv + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Cprv extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_cprv"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Cprv() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)18; i++ ) + { + /* Case 1 to 18: Send Unrecognized Envelope with Tag 82, length 02 + Tag 06, length 06 + Tag 8B, length 24. + */ + response = test.sendApdu( "80 C2 00 00 34" + + "01 32" + + "82 02 83 81" + + "06 06" + + "81112233 44F5" + + "8B 24" + + "40088155 6677887F F6001129 12000004" + + "13027000 000E0D08 00000028 83850000" + + "00000100"); + if(i == 0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "12CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a84b84533e1155d7b86bcf3d24eab7268525ca95 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_cprv.Api_2_Enh_Cprv_1 +uicc.test.toolkit.api_2_enh_cprv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/javacard/api_2_enh_cprv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/javacard/api_2_enh_cprv.cap new file mode 100644 index 0000000000000000000000000000000000000000..e6c6dccc9f8fdc98338e10d265dfb3b97a5e6474 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cprv/javacard/api_2_enh_cprv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/Api_2_Enh_Cpyv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/Api_2_Enh_Cpyv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..4c4c5159d697704b0a57ce2a98d4002740f618b5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/Api_2_Enh_Cpyv_1.java @@ -0,0 +1,430 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Cpyv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_cpyv; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; +/** + * Test Area : uicc.test.toolkit.Api_2_enh_Cpyv + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Cpyv_1 extends TestToolkitApplet +{ + private final byte[] compBuffer = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06}; + private final byte[] compBuffer2= {(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55, + (byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55}; + + private byte[] dstBuffer; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Cpyv_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Cpyv_1 thisApplet = new Api_2_Enh_Cpyv_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the copyValue method with an destination Buffer null + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.copyValue((short)0,null,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the copyValue method with an offset > buffer length + testCaseNb = (byte) 2 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)5,(short)1)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the copyValue method with an offset = -1 + testCaseNb = (byte) 3 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)-1,(short)1)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the copyValue method with an length > buffer length + testCaseNb = (byte) 4 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)0,(short)6)==6)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : use the copyValue method with an Offset + length > buffer length + testCaseNb = (byte) 5 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)3,(short)3)==6)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the copyValue method with an dstLength < 0 + testCaseNb = (byte) 6 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)0,(short)-1)==0)) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : use the copyValue method with ValueOffset > TLV length + testCaseNb = (byte) 7 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)6,dstBuffer,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : use the copyValue method with ValueOffset < 0 + testCaseNb = (byte) 8 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)-1,dstBuffer,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : use the copyValue method with dstlength > TLV length + testCaseNb = (byte) 9 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)0,(short)7)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : use the copyValue method with ValueOffset+dstlength > TLV length + testCaseNb = (byte) 10 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)2,dstBuffer,(short)0,(short)5)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : use the copyValue method without current TVL + testCaseNb = (byte) 11 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x01,(byte)1)==TLV_NOT_FOUND) + &&(envHdlr.copyValue((short)2,dstBuffer,(short)0,(short)5)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 11 : + // -------------------------------------------- + // Test Case 12 : use successfully the copyValue method + testCaseNb = (byte) 12 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)0,(short)6)==6)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 12 : + // -------------------------------------------- + // Test Case 13 : use successfully the copyValue method and compare the received data + testCaseNb = (byte) 13 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)0,(short)6)==6) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer,(short)0, (short) compBuffer.length)==0)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 13 : + // -------------------------------------------- + // Test Case 14 : use successfully the copyValue + testCaseNb = (byte) 14 ; + + bRes = false ; + dstBuffer =new byte[20]; + + // initialize the buffer + for(byte i=0;i<20;i++) + dstBuffer[i] =(byte)0x55; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)1,dstBuffer,(short)3,(short)4)==7)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 15 : use successfully the copyValue method and compare the received data + testCaseNb = (byte) 15 ; + + bRes = false ; + dstBuffer =new byte[32]; + + // initialize the buffer + for(byte i=0;i<32;i++) + dstBuffer[i] =(byte)0x55; + + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)1,dstBuffer,(short)3,(short)4)==7) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer2,(short)0, (short) compBuffer2.length)==0)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 15 : + // -------------------------------------------- + // Test Case 16 : use successfully the copyValue method with the length of the copy =0 + testCaseNb = (byte) 16 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.copyValue((short)0,dstBuffer,(short)dstBuffer.length,(short)0)==dstBuffer.length)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/Test_Api_2_Enh_Cpyv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/Test_Api_2_Enh_Cpyv.java new file mode 100644 index 0000000000000000000000000000000000000000..a2482de9c2fb30dc6003f6be830d3d68f15a8769 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/Test_Api_2_Enh_Cpyv.java @@ -0,0 +1,130 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Cpyv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_cpyv; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Cpyv + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Cpyv extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_cpyv"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Cpyv() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)16; i++ ) + { + /* 1: Send Unrecognized Envelope with Tag 02, length 02 + Tag 06, length 06 + Tag 33, length C7. + */ + response = test.sendApdu( "80 C2 00 00 D9" + + "01 81 D6" + + "02 02 83 81" + + "86 06" + + "01020304 0506" + + "33 81 C7" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 01010101 01010101 01010101" + + "01010101 010101"); + if(i == 0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "10CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a163562ea270bc465314ac63f579eb5299be410d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_cpyv.Api_2_Enh_Cpyv_1 +uicc.test.toolkit.api_2_enh_cpyv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/javacard/api_2_enh_cpyv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/javacard/api_2_enh_cpyv.cap new file mode 100644 index 0000000000000000000000000000000000000000..9f63444adf7a39a755ec55bb327254cbe34cb1dc Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_cpyv/javacard/api_2_enh_cpyv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/Api_2_Enh_Facrb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/Api_2_Enh_Facrb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..28b09aaf624c90f765cc05a3da897a0b82278c2a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/Api_2_Enh_Facrb_Bs_1.java @@ -0,0 +1,430 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Facyb_Bs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facrb_bs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bs + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Facrb_Bs_1 extends TestToolkitApplet +{ + + /** Registry entry concerning applet instance */ + + private byte[] CompareBuffer; + private byte[] CompareBuffer2 = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4}; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Facrb_Bs_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Facrb_Bs_1 thisApplet = new Api_2_Enh_Facrb_Bs_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the findAndCompareValue method with an destination Buffer null + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if(envHdlr.findAndCompareValue((byte)2,null,(short)0)==0) + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the findAndCompareValue method with an offset > buffer length + testCaseNb = (byte) 2 ; + + bRes = false ; + CompareBuffer =new byte[6]; + try { + if(envHdlr.findAndCompareValue((byte)6,CompareBuffer,(short)6)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the findAndCompareValue method with an offset <0 + testCaseNb = (byte) 3 ; + + bRes = false ; + CompareBuffer =new byte[6]; + try { + if(envHdlr.findAndCompareValue((byte)6,CompareBuffer,(short)-1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the findAndCompareValue method with an length > buffer length + testCaseNb = (byte) 4 ; + + bRes = false ; + CompareBuffer =new byte[5]; + try { + if(envHdlr.findAndCompareValue((byte)6,CompareBuffer,(short)0)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : use the findAndCompareValue method with an Offset + length > buffer length + testCaseNb = (byte) 5 ; + + bRes = false ; + CompareBuffer =new byte[6]; + try { + if(envHdlr.findAndCompareValue((byte)6,CompareBuffer,(short)1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the findAndCompareValue method without current tlv + testCaseNb = (byte) 6 ; + + bRes = false ; + CompareBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x02,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.findAndCompareValue((byte)3,CompareBuffer,(short)0)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // use the method getValueLength() after the unsuccessful of the method findAndCompareValue + testCaseNb = (byte) 7 ; + bRes = false; + try { + if(envHdlr.getValueLength()==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : normal execution of the findAndCompareValue() method with the TAG 06 + testCaseNb = (byte) 8 ; + + bRes = false ; + CompareBuffer =new byte[6]; + CompareBuffer[0] = (byte) 0x81; + CompareBuffer[1] = (byte) 0x11; + CompareBuffer[2] = (byte) 0x22; + CompareBuffer[3] = (byte) 0x33; + CompareBuffer[4] = (byte) 0x44; + CompareBuffer[5] = (byte) 0xF5; + + try { + if((envHdlr.findAndCompareValue((byte)0x06,CompareBuffer,(byte)0)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : normal execution of the findAndCompareValue() method and getValueLength() + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + if((envHdlr.findAndCompareValue((byte)0x06,CompareBuffer,(byte)0)==0) + &&(envHdlr.getValueLength()==6)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) with the TAG 06 + testCaseNb = (byte) 10 ; + + bRes = false ; + CompareBuffer[5] = (byte) 0xF4; + + try { + if(envHdlr.findAndCompareValue((byte)0x06,CompareBuffer,(byte)0)==(byte)1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 11 ; + + bRes = false ; + CompareBuffer[5] = (byte) 0xF6; + + try { + if(envHdlr.findAndCompareValue((byte)0x06,CompareBuffer,(byte)0)== (byte)(-1)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 11 : + // -------------------------------------------- + // Test Case 12 : normal execution of the findAndCompareValue method with the TAG 02 + testCaseNb = (byte) 12 ; + + bRes = false ; + CompareBuffer =new byte[12]; + for( byte i=0;i<12;i++) + CompareBuffer[i]=0x55; + CompareBuffer[2] = (byte) 0x81; + CompareBuffer[3] = (byte) 0x11; + CompareBuffer[4] = (byte) 0x22; + CompareBuffer[5] = (byte) 0x33; + CompareBuffer[6] = (byte) 0x44; + CompareBuffer[7] = (byte) 0xF5; + try { + if(envHdlr.findAndCompareValue((byte)0x06,CompareBuffer,(byte)2)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 12 : + // -------------------------------------------- + // Test Case 13 : normal execution of the findAndCompareValue method with the TAG 02 and compare the stored Values + testCaseNb = (byte) 13 ; + + bRes = false ; + for( byte i=0;i<12;i++) + CompareBuffer[i]=0x55; + CompareBuffer[2] = (byte) 0x83; + CompareBuffer[3] = (byte) 0x81; + + try { + if(envHdlr.findAndCompareValue((byte)0x02,CompareBuffer,(byte)2)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 13 : + // -------------------------------------------- + // Test Case 14 : normal execution of the findAndCompareValue method with the TAG 82 + testCaseNb = (byte) 14 ; + + bRes = false ; + CompareBuffer[3] = (byte)0x80; + + try { + if(envHdlr.findAndCompareValue((byte)0x82,CompareBuffer,(byte)2)==(byte)1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 15 : normal execution of the findAndCompareValue method with the TAG 82 and compare the stored Values + testCaseNb = (byte) 15 ; + + bRes = false ; + CompareBuffer[3] = (byte)0x82; + + try { + if(envHdlr.findAndCompareValue((byte)0x82,CompareBuffer,(byte)2)==(byte)(-1)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 15 : + // -------------------------------------------- + // Test Case 16 : normal execution of the findAndCompareValue method with the TAG B3 + testCaseNb = (byte) 16 ; + + bRes = false ; + for( byte i=0;i<12;i++) + CompareBuffer[i]=0x55; + CompareBuffer[0] = (byte) 0x83; + CompareBuffer[1] = (byte) 0x81; + + try { + if(envHdlr.findAndCompareValue((byte)0x02,CompareBuffer,(byte)0)==0) + bRes = true; + } + + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 16 : + // -------------------------------------------- + // Test Case 17 : normal execution of the findAndCompareValue method with the TAG B3 and compare the stored Values + testCaseNb = (byte) 17 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)0xB3,CompareBuffer2,(byte)0)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/Test_Api_2_Enh_Facrb_Bs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/Test_Api_2_Enh_Facrb_Bs.java new file mode 100644 index 0000000000000000000000000000000000000000..38d5a4feae1fe8394300bfa291cf9da334759f91 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/Test_Api_2_Enh_Facrb_Bs.java @@ -0,0 +1,131 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Facyb_Bs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facrb_bs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bs + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Facrb_Bs extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_facrb_bs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Facrb_Bs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)16; i++ ) + { + /* Case 1 to 18: Send Unrecognized Envelope with Tag 82, length 02 + Tag 06, length 06 + Tag 8B, length 24. + */ + response = test.sendApdu( "80 C2 00 00 DA" + + "01 81 D7" + + "02 02 83 81" + + "06 06" + + "81112233 44F5" + + "02 02 22 44" + + "33 81 C4" + + "01020304 05060708 090A0B 0C0D0E0F10" + + "11121314 15161718 191A1B 1C1D1E1F20" + + "21222324 25262728 292A2B 2C2D2E2F30" + + "31323334 35363738 393A3B 3C3D3E3F40" + + "41424344 45464748 494A4B 4C4D4E4F50" + + "51525354 55565758 595A5B 5C5D5E5F60" + + "61626364 65666768 696A6B 6C6D6E6F70" + + "71727374 75767778 797A7B 7C7D7E7F80" + + "81828384 85868788 898A8B 8C8D8E8F90" + + "91929394 95969798 999A9B 9C9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAAB ACADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABB BCBDBEBFC0" + + "C1C2C3C4"); + if(i==0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "11CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b2876209aeb6c0d4b554257ae01a9951538b5b0d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_facrb_bs.Api_2_Enh_Facrb_Bs_1 +uicc.test.toolkit.api_2_enh_facrb_bs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/javacard/api_2_enh_facrb_bs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/javacard/api_2_enh_facrb_bs.cap new file mode 100644 index 0000000000000000000000000000000000000000..1f36e469ad034ec80fe51217fbc8c8e1c19953d5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrb_bs/javacard/api_2_enh_facrb_bs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/Api_2_Enh_Facrbbs_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/Api_2_Enh_Facrbbs_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..59242dd433c401611408c962adb53e6f49217296 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/Api_2_Enh_Facrbbs_Bss_1.java @@ -0,0 +1,616 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Facyb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facrbbs_bss; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bss + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Facrbbs_Bss_1 extends TestToolkitApplet +{ + + /** Registry entry concerning applet instance */ + private final byte[] compBuffer = {(byte)0x81,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF5}; + + private final byte[] compBuffer2= {(byte)0x81,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF4}; + + private final byte[] compBuffer3= {(byte)0x81,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF6}; + + private byte[] compBuffer4; + + private byte[] compBuffer5; + private byte[] compBuffer6 = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4}; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Facrbbs_Bss_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Facrbbs_Bss_1 thisApplet = new Api_2_Enh_Facrbbs_Bss_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the findAndCopyValue method with an destination Buffer null + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if(envHdlr.findAndCompareValue((byte)2,(byte)1,(short)0,null,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the findAndCompareValue method with an offset > buffer length + testCaseNb = (byte) 2 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer,(short)6,(short)1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the findAndCompareValue method with an offset <0 + testCaseNb = (byte) 3 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer,(short)-1,(short)1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the findAndCompareValue method with an length > buffer length + testCaseNb = (byte) 4 ; + + bRes = false ; + + try { + byte[] SmallCompBuffer = new byte[5]; + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,SmallCompBuffer,(short)0,(short)6)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : use the findAndCompareValue method with an Offset + length > buffer length + testCaseNb = (byte) 5 ; + + bRes = false ; + compBuffer4 = new byte[7]; + compBuffer4[0] = (byte) 0x81; + compBuffer4[1] = (byte) 0x11; + compBuffer4[2] = (byte) 0x22; + compBuffer4[3] = (byte) 0x33; + compBuffer4[4] = (byte) 0x44; + compBuffer4[5] = (byte) 0xF5; + compBuffer4[6] = (byte) 0x00; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer,(short)4,(short)3)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the findAndCompareValue method with an dstlength < 0 + testCaseNb = (byte) 6 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer,(short)0,(short)-1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : use the findAndCompareValue method with an ValueOffset > buffer length + testCaseNb = (byte) 7 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)6,compBuffer,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : use the findAndCompareValue method with an ValueOffset <0 + testCaseNb = (byte) 8 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)-1,compBuffer,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : use the findAndCompareValue method with an CompareLength > Value length + testCaseNb = (byte) 9 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer4,(short)0,(short)7)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : use the findAndCompareValue method with an ValueOffset + dstlength > ValueLength + testCaseNb = (byte) 10 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)2,compBuffer,(short)0,(short)5)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : use the findAndCompareValue method with occurence set to 0 + testCaseNb = (byte) 11 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)0,(short)0,compBuffer,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.BAD_INPUT_PARAMETER) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 11 : + // -------------------------------------------- + // Test case 12 : Unsuccessful of the method findAndCompareValue with wrong occurence + testCaseNb = (byte) 12 ; + bRes = false; + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)2,(short)0,compBuffer,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 12 : + // -------------------------------------------- + // Test Case 13 : Call the getValueLength() method after unsuccessful of the findAndCompareValue method with the TAG 06 + testCaseNb = (byte) 13 ; + + bRes = false ; + + try { + if((envHdlr.findAndCompareValue((byte)6,(byte)2,(short)0,compBuffer,(short)0,(short)6)==6) + &&(envHdlr.getValueLength()==0)) + bRes = false; + } + + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 13 : + // -------------------------------------------- + // Test Case 14 : normal execution of the findAndCompareValue method with the TAG 06 and compare the stored value + testCaseNb = (byte) 14 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer,(short)0,(short)6)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 15 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) with the TAG 06 + testCaseNb = (byte) 15 ; + + bRes = false ; + + try { + if((envHdlr.findAndCompareValue((byte)6,(byte)1,(short)0,compBuffer,(short)0,(short)6)==0) + &&(envHdlr.getValueLength())==6) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 15 : + // -------------------------------------------- + // Test Case 16 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 16 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)0x06,(byte)1,(short)0,compBuffer2,(short)0,(short)6)==1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 16 : + // -------------------------------------------- + // Test Case 17 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) with the TAG 02 + testCaseNb = (byte) 17 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)0x06,(byte)1,(short)0,compBuffer3,(short)0,(short)6)==-1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 17 : + // -------------------------------------------- + // Test Case 17 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 18 ; + + bRes = false ; + compBuffer4 = new byte[11]; + + for( byte i=0;i<11;i++) + compBuffer4[i]=0x55; + compBuffer4[3] = (byte)0x22; + compBuffer4[4] = (byte)0x33; + compBuffer4[5] = (byte)0x44; + compBuffer4[6] = (byte)0xF5; + + try { + if(envHdlr.findAndCompareValue((byte)0x06,(byte)1,(short)2,compBuffer4,(short)3,(short)4)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 18 : + // -------------------------------------------- + // Test Case 18 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) with the TAG 02 and the occurence 2 + testCaseNb = (byte) 19 ; + + bRes = false ; + compBuffer4[5] = (byte)0x45; + + try { + if(envHdlr.findAndCompareValue((byte)0x06,(byte)1,(short)2,compBuffer4,(short)3,(short)4)==-1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 19 : + // -------------------------------------------- + // Test Case 19 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 20 ; + + bRes = false ; + compBuffer4[5] = (byte)0x43; + try { + if(envHdlr.findAndCompareValue((byte)0x06,(byte)1,(short)2,compBuffer4,(short)3,(short)4)==1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 20 : + // -------------------------------------------- + // Test Case 20 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) with the TAG 82 and the occurence 1 + testCaseNb = (byte) 21 ; + + bRes = false ; + compBuffer5 = new byte[12]; + for( byte i=0;i<12;i++) + compBuffer5[i]=0x55; + compBuffer5[0] = (byte)0x83; + compBuffer5[1] = (byte)0x81; + + try { + if(envHdlr.findAndCompareValue((byte)0x82,(byte)1,(short)0,compBuffer5,(short)0,(short)2)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 21 : + // -------------------------------------------- + // Test Case 21 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 22 ; + + bRes = false ; + compBuffer5[0] = (byte)0x22; + compBuffer5[1] = (byte)0x44; + + try { + if(envHdlr.findAndCompareValue((byte)0x82,(byte)2,(short)0,compBuffer5,(short)0,(short)2)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 22 : + // -------------------------------------------- + // Test Case 22 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) with the TAG 82 and the occurence 2 + testCaseNb = (byte) 23 ; + + bRes = false ; + compBuffer5[1] = (byte)0x45; + + try { + if(envHdlr.findAndCompareValue((byte)0x82,(byte)2,(short)0,compBuffer5,(short)0,(short)2)== -1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 23 : + // -------------------------------------------- + // Test Case 23 : use the findAndCompareValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 24 ; + + bRes = false ; + compBuffer5[0] = (byte)0x83; + compBuffer5[1] = (byte)0x81; + + try { + if(envHdlr.findAndCompareValue((byte)0x82,(byte)1,(short)0,compBuffer5,(short)0,(short)2)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 24 : + // -------------------------------------------- + // Test Case 24 : Successful call with tag B3 + testCaseNb = (byte) 25 ; + + bRes = false ; + + try { + if(envHdlr.findAndCompareValue((byte)0xB3,(byte)1,(short)0,compBuffer6,(short)0,(short)compBuffer6.length)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 25 : + // -------------------------------------------- + // Test Case 26 : use the findAndCompareValue method with compareLength = 0 + testCaseNb = (byte) 26 ; + + bRes = false ; + try { + if(envHdlr.findAndCompareValue((byte)0x33,(byte)1,(short)0,compBuffer6,(short)0,(short)0)==0) + bRes = true; + } + + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/Test_Api_2_Enh_Facrbbs_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/Test_Api_2_Enh_Facrbbs_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..e0421e215060f8fe0d4be3d60dec7aaf7c166bdc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/Test_Api_2_Enh_Facrbbs_Bss.java @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Facyb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facrbbs_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facrbbs_Bss + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Facrbbs_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_facrbbs_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Facrbbs_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)26; i++ ) + { + /* Case 1 to 18: Send Unrecognized Envelope with Tag 82, length 02 + Tag 06, length 06 + Tag 8B, length 24. + */ + response = test.sendApdu( "80 C2 00 00 DA" + + "01 81 D7" + + "02 02 83 81" + + "06 06" + + "81112233 44F5" + + "02 02 22 44" + + "33 81 C4" + + "01020304 05060708 090A0B 0C0D0E0F10" + + "11121314 15161718 191A1B 1C1D1E1F20" + + "21222324 25262728 292A2B 2C2D2E2F30" + + "31323334 35363738 393A3B 3C3D3E3F40" + + "41424344 45464748 494A4B 4C4D4E4F50" + + "51525354 55565758 595A5B 5C5D5E5F60" + + "61626364 65666768 696A6B 6C6D6E6F70" + + "71727374 75767778 797A7B 7C7D7E7F80" + + "81828384 85868788 898A8B 8C8D8E8F90" + + "91929394 95969798 999A9B 9C9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAAB ACADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABB BCBDBEBFC0" + + "C1C2C3C4"); + if(i == 0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "1ACCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..20e8bc59d50926b55e9bb7e19ce2ed09ca5a2f4c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_facrbbs_bss.Api_2_Enh_Facrbbs_Bss_1 +uicc.test.toolkit.api_2_enh_facrbbs_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/javacard/api_2_enh_facrbbs_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/javacard/api_2_enh_facrbbs_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..2ca6427bfbd04f66146ca8617389b39be02700c1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facrbbs_bss/javacard/api_2_enh_facrbbs_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/Api_2_Enh_Facyb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/Api_2_Enh_Facyb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1cd96160e90d2697224a8160692b2729d42dfbd7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/Api_2_Enh_Facyb_Bs_1.java @@ -0,0 +1,432 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Facyb_Bs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facyb_bs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bs + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Facyb_Bs_1 extends TestToolkitApplet +{ + + /** Registry entry concerning applet instance */ + //private ToolkitRegistry obReg; + + private final byte[] compBuffer = {(byte)0x81,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF5}; + + private final byte[] compBuffer2= {(byte)0x55,(byte)0x55,(byte)0x81,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF5,(byte)0x55,(byte)0x55, + (byte)0x55,(byte)0x55}; + + private final byte[] compBuffer3= {(byte)0x83,(byte)0x81}; + + private final byte[] compBuffer4= {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4}; + + private byte[] compBuffer5; + + private byte[] dstBuffer; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Facyb_Bs_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Facyb_Bs_1 thisApplet = new Api_2_Enh_Facyb_Bs_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the findAndCopyValue method with an destination Buffer null + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if(envHdlr.findAndCopyValue((byte)2,null,(short)0)==0) + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the findAndCopyValue method with an offset > buffer length + testCaseNb = (byte) 2 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if(envHdlr.findAndCopyValue((byte)6,dstBuffer,(short)6)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the findAndCopyValue method with an offset <0 + testCaseNb = (byte) 3 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if(envHdlr.findAndCopyValue((byte)6,dstBuffer,(short)-1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the findAndCopyValue method with an length > buffer length + testCaseNb = (byte) 4 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if(envHdlr.findAndCopyValue((byte)6,dstBuffer,(short)0)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : use the findAndCopyValue method with an Offset + length > buffer length + testCaseNb = (byte) 5 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if(envHdlr.findAndCopyValue((byte)6,dstBuffer,(short)1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the findAndCopyValue method without current tlv + testCaseNb = (byte) 6 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if((envHdlr.findTLV((byte)0x02,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.findAndCopyValue((byte)3,dstBuffer,(short)0)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // use the method getValueLength() after the unsuccessful of the method findAndCopyValue + testCaseNb = (byte) 7 ; + bRes = false; + try { + if(envHdlr.getValueLength()==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 7 : + // -------------------------------------------- + // Test Case 7 : normal execution of the findAndCopyValue() method with the TAG 06 + testCaseNb = (byte) 8 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if((envHdlr.findAndCopyValue((byte)0x06,dstBuffer,(byte)0)==6)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 8 : normal execution of the findAndCopyValue() method and compare the buffer value with the TAG 06 + testCaseNb = (byte) 9 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if((envHdlr.findAndCopyValue((byte)0x06,dstBuffer,(byte)0)==6) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer,(short)0, (short) compBuffer.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 9 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) with the TAG 06 + testCaseNb = (byte) 10 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if(envHdlr.findAndCopyValue((byte)0x06,dstBuffer,(byte)2)==8) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 10 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 11 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if((envHdlr.findAndCopyValue((byte)0x06,dstBuffer,(byte)2)==8) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer2,(short)0, (short) compBuffer2.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 11 : + // -------------------------------------------- + // Test Case 11 : normal execution of the findAndCopyValue method with the TAG 02 + testCaseNb = (byte) 12 ; + + bRes = false ; + dstBuffer =new byte[2]; + + try { + if(envHdlr.findAndCopyValue((byte)0x02,dstBuffer,(byte)0)==2) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 12 : + // -------------------------------------------- + // Test Case 12 : normal execution of the findAndCopyValue method with the TAG 02 and compare the stored Values + testCaseNb = (byte) 13 ; + + bRes = false ; + dstBuffer =new byte[2]; + + try { + if((envHdlr.findAndCopyValue((byte)0x02,dstBuffer,(byte)0)==2) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer3,(short)0, (short) compBuffer3.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 13 : + // -------------------------------------------- + // Test Case 13 : normal execution of the findAndCopyValue method with the TAG 82 + testCaseNb = (byte) 14 ; + + bRes = false ; + dstBuffer =new byte[2]; + + try { + if(envHdlr.findAndCopyValue((byte)0x82,dstBuffer,(byte)0)==2) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 14 : normal execution of the findAndCopyValue method with the TAG 82 and compare the stored Values + testCaseNb = (byte) 15 ; + + bRes = false ; + dstBuffer =new byte[2]; + + try { + if((envHdlr.findAndCopyValue((byte)0x82,dstBuffer,(byte)0)==2) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer3,(short)0, (short) compBuffer3.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 15 : + // -------------------------------------------- + // Test Case 16 : normal execution of the findAndCopyValue method with the TAG B3 + testCaseNb = (byte) 16 ; + + bRes = false ; + dstBuffer =new byte[0xC4]; + + try { + if(envHdlr.findAndCopyValue((byte)0xB3,dstBuffer,(byte)0)==0xC4) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 16 : + // -------------------------------------------- + // Test Case 17 : normal execution of the findAndCopyValue method with the TAG B3 and compare the stored Values + testCaseNb = (byte) 17 ; + + bRes = false ; + dstBuffer =new byte[0xC4]; + + try { + if((envHdlr.findAndCopyValue((byte)0xB3,dstBuffer,(byte)0)==0xC4) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer4,(short)0, (short) compBuffer4.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/Test_Api_2_Enh_Facyb_Bs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/Test_Api_2_Enh_Facyb_Bs.java new file mode 100644 index 0000000000000000000000000000000000000000..0bca5d1b0cd06ab61ccec2718a629f73412f68d6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/Test_Api_2_Enh_Facyb_Bs.java @@ -0,0 +1,132 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Facyb_Bs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facyb_bs; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bs + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Facyb_Bs extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_facyb_bs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Facyb_Bs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + for(byte i = 0; i <= (byte)17; i++ ) + { + /* Case 1 to 18: Send Unrecognized Envelope with Tag 82, length 02 + Tag 06, length 06 + Tag 8B, length 24. + */ + response = test.sendApdu( "80 C2 00 00 DA" + + "01 81 D7" + + "02 02 83 81" + + "06 06" + + "81112233 44F5" + + "02 02 22 44" + + "33 81 C4" + + "01020304 05060708 090A0B 0C0D0E0F10" + + "11121314 15161718 191A1B 1C1D1E1F20" + + "21222324 25262728 292A2B 2C2D2E2F30" + + "31323334 35363738 393A3B 3C3D3E3F40" + + "41424344 45464748 494A4B 4C4D4E4F50" + + "51525354 55565758 595A5B 5C5D5E5F60" + + "61626364 65666768 696A6B 6C6D6E6F70" + + "71727374 75767778 797A7B 7C7D7E7F80" + + "81828384 85868788 898A8B 8C8D8E8F90" + + "91929394 95969798 999A9B 9C9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAAB ACADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABB BCBDBEBFC0" + + "C1C2C3C4"); + if(i==0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "11CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..e37e1bbb644da99e02de4b6573bfc4d78ec5e1ec --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_facyb_bs.Api_2_Enh_Facyb_Bs_1 +uicc.test.toolkit.api_2_enh_facyb_bs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/javacard/api_2_enh_facyb_bs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/javacard/api_2_enh_facyb_bs.cap new file mode 100644 index 0000000000000000000000000000000000000000..e8f89570f882ef2d3834905ae18c273767d99d8e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bs/javacard/api_2_enh_facyb_bs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/Api_2_Enh_Facyb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/Api_2_Enh_Facyb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3953228c413b619cba619eeb74e4ba247c0e96b5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/Api_2_Enh_Facyb_Bss_1.java @@ -0,0 +1,625 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Facyb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facyb_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bss + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Facyb_Bss_1 extends TestToolkitApplet +{ + + /** Registry entry concerning applet instance */ + private final byte[] compBuffer = {(byte)0x81,(byte)0x11,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF5}; + + private final byte[] compBuffer2= {(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x22,(byte)0x33,(byte)0x44,(byte)0xF5,(byte)0x55,(byte)0x55,(byte)0x55, + (byte)0x55,(byte)0x55}; + + private final byte[] compBuffer3= {(byte)0x83,(byte)0x81,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55, + (byte)0x55,(byte)0x55}; + + private final byte[] compBuffer4= {(byte)0x22,(byte)0x44,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55,(byte)0x55, + (byte)0x55,(byte)0x55}; + + private byte[] compBuffer5; + private byte[] dstBuffer; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Facyb_Bss_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Facyb_Bss_1 thisApplet = new Api_2_Enh_Facyb_Bss_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the findAndCopyValue method with an destination Buffer null + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if(envHdlr.findAndCopyValue((byte)2,(byte)1,(short)0,null,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + bRes = false; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the findAndCopyValue method with an offset > buffer length + testCaseNb = (byte) 2 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)5,(short)1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the findAndCopyValue method with an offset <0 + testCaseNb = (byte) 3 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)-1,(short)1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the findAndCopyValue method with an length > buffer length + testCaseNb = (byte) 4 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)0,(short)6)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : use the findAndCopyValue method with an Offset + length > buffer length + testCaseNb = (byte) 5 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)3,(short)3)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the findAndCopyValue method with an dstlength < 0 + testCaseNb = (byte) 6 ; + + bRes = false ; + dstBuffer =new byte[5]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)0,(short)-1)==0) + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : use the findAndCopyValue method with an ValueOffset > buffer length + testCaseNb = (byte) 7 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)6,dstBuffer,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : use the findAndCopyValue method with an ValueOffset <0 + testCaseNb = (byte) 8 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)-1,dstBuffer,(short)0,(short)1)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : use the findAndCopyValue method with an dstLength > Value length + testCaseNb = (byte) 9 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)0,(short)7)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : use the findAndCopyValue method with an ValueOffset + dstlength > ValueLength + testCaseNb = (byte) 10 ; + + bRes = false ; + dstBuffer =new byte[15]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)2,dstBuffer,(short)0,(short)5)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : use the findAndCopyValue method without the researched TAG + testCaseNb = (byte) 11 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if((envHdlr.findTLV((byte)0x02,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.findAndCopyValue((byte)6,(byte)2,(short)0,dstBuffer,(short)0,(short)1)==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // use the method getValueLength() after the unsuccessful of the method findAndCopyValue + testCaseNb = (byte) 12 ; + bRes = false; + try { + if(envHdlr.getValueLength()==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 12 : + // -------------------------------------------- + // Test Case 12 : normal execution of the findAndCopyValue method with the TAG 06 + testCaseNb = (byte) 13 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if(envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)0,(short)6)==6) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 13 : + // -------------------------------------------- + // Test Case 13 : normal execution of the findAndCopyValue method with the TAG 06 and compare the stored value + testCaseNb = (byte) 14 ; + + bRes = false ; + dstBuffer =new byte[6]; + try { + if((envHdlr.findAndCopyValue((byte)6,(byte)1,(short)0,dstBuffer,(short)0,(short)6)==6) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer,(short)0, (short) compBuffer.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 14 : + // -------------------------------------------- + // Test Case 14 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) with the TAG 06 + testCaseNb = (byte) 15 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if(envHdlr.findAndCopyValue((byte)0x06,(byte)1,(short)2,dstBuffer,(short)3,(short)4)==7) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 15 : + // -------------------------------------------- + // Test Case 15 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 16 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if((envHdlr.findAndCopyValue((byte)0x06,(byte)1,(short)2,dstBuffer,(short)3,(short)4)==7) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer2,(short)0, (short) compBuffer2.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 16 : + // -------------------------------------------- + // Test Case 16 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) with the TAG 02 + testCaseNb = (byte) 17 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if(envHdlr.findAndCopyValue((byte)0x02,(byte)1,(short)0,dstBuffer,(short)0,(short)2)==2) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 17 : + // -------------------------------------------- + // Test Case 17 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 18 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if((envHdlr.findAndCopyValue((byte)0x02,(byte)1,(short)0,dstBuffer,(short)0,(short)2)==2) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer3,(short)0, (short) compBuffer3.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + + case (byte) 18 : + // -------------------------------------------- + // Test Case 18 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) with the TAG 02 and the occurence 2 + testCaseNb = (byte) 19 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if(envHdlr.findAndCopyValue((byte)0x02,(byte)2,(short)0,dstBuffer,(short)0,(short)2)==2) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 19 : + // -------------------------------------------- + // Test Case 19 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 20 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if((envHdlr.findAndCopyValue((byte)0x02,(byte)2,(short)0,dstBuffer,(short)0,(short)2)==2) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer4,(short)0, (short) compBuffer4.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 20 : + // -------------------------------------------- + // Test Case 20 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) with the TAG 82 and the occurence 1 + testCaseNb = (byte) 21 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if(envHdlr.findAndCopyValue((byte)0x82,(byte)1,(short)0,dstBuffer,(short)0,(short)2)==2) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 21 : + // -------------------------------------------- + // Test Case 21 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 22 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if((envHdlr.findAndCopyValue((byte)0x82,(byte)1,(short)0,dstBuffer,(short)0,(short)2)==2) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer3,(short)0, (short) compBuffer3.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 22 : + // -------------------------------------------- + // Test Case 22 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) with the TAG 82 and the occurence 2 + testCaseNb = (byte) 23 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if(envHdlr.findAndCopyValue((byte)0x82,(byte)2,(short)0,dstBuffer,(short)0,(short)2)==2) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 23 : + // -------------------------------------------- + // Test Case 23 : use the findAndCopyValue method (store the TLV value in a fulfilled buffer) and compare the stored values + testCaseNb = (byte) 24 ; + + bRes = false ; + dstBuffer =new byte[12]; + + for( byte i=0;i<12;i++) + dstBuffer[i]=0x55; + + try { + if((envHdlr.findAndCopyValue((byte)0x82,(byte)2,(short)0,dstBuffer,(short)0,(short)2)==2) + &&(Util.arrayCompare(dstBuffer,(short)0,compBuffer4,(short)0, (short) compBuffer4.length)==0)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 24 : + // -------------------------------------------- + // Test Case 24 : use the findAndCopyValue method (with the length = 0 and the offset = length of the destination buffer) + testCaseNb = (byte) 25 ; + + bRes = false ; + try { + if(envHdlr.findAndCopyValue((byte)0x82,(byte)2,(short)0,dstBuffer,(short)dstBuffer.length,(short)0)==dstBuffer.length) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 25 : + // -------------------------------------------- + // Test Case 26 : use the findAndCopyValue method with Invalid Parameter(occurrence = 0) + testCaseNb = (byte) 26 ; + + bRes = false ; + dstBuffer =new byte[0x10D]; + + try { + if(envHdlr.findAndCopyValue((byte)0x0B,(byte)0,(short)0x11,dstBuffer,(short)0,(short)0x10D)==0x10D) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.BAD_INPUT_PARAMETER) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/Test_Api_2_Enh_Facyb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/Test_Api_2_Enh_Facyb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..d10b3af05e9e34cf1ec51cdd7156564417af341f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/Test_Api_2_Enh_Facyb_Bss.java @@ -0,0 +1,132 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Facyb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_facyb_bss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Facyb_Bss + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Facyb_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_facyb_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Facyb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)26; i++ ) + { + /* Case 1 to 18: Send Unrecognized Envelope with Tag 82, length 02 + Tag 06, length 06 + Tag 8B, length 24. + */ + response = test.sendApdu( "80 C2 00 00 DA" + + "01 81 D7" + + "02 02 83 81" + + "06 06" + + "81112233 44F5" + + "02 02 22 44" + + "33 81 C4" + + "01020304 05060708 090A0B 0C0D0E0F10" + + "11121314 15161718 191A1B 1C1D1E1F20" + + "21222324 25262728 292A2B 2C2D2E2F30" + + "31323334 35363738 393A3B 3C3D3E3F40" + + "41424344 45464748 494A4B 4C4D4E4F50" + + "51525354 55565758 595A5B 5C5D5E5F60" + + "61626364 65666768 696A6B 6C6D6E6F70" + + "71727374 75767778 797A7B 7C7D7E7F80" + + "81828384 85868788 898A8B 8C8D8E8F90" + + "91929394 95969798 999A9B 9C9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAAB ACADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABB BCBDBEBFC0" + + "C1C2C3C4"); + if(i == 0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "1ACCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..e1b3ee2f4d729b1d711d4096053b7b93712ae1b7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_facyb_bss.Api_2_Enh_Facyb_Bss_1 +uicc.test.toolkit.api_2_enh_facyb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/javacard/api_2_enh_facyb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/javacard/api_2_enh_facyb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..ec0829faf68f3ba2bd44cb2114ffcee12117ae86 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_facyb_bss/javacard/api_2_enh_facyb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/Api_2_Enh_Find_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/Api_2_Enh_Find_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3659f91cf08486582ca1f26b2c310542904797af --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/Api_2_Enh_Find_1.java @@ -0,0 +1,325 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Find_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_find; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Find + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Find_1 extends TestToolkitApplet +{ + + private byte[] dstBuffer; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Find_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Find_1 thisApplet = new Api_2_Enh_Find_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short arg0) throws ToolkitException + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : invalid input parametre: the occurence =0 + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + envHdlr.findTLV((byte)2,(byte)0); + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.BAD_INPUT_PARAMETER) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : search the first TVL with the TAG 02 (CR is Set) + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_SET) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : verify that this TLV is the the current TLV (device identity) + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.getValueLength()==2)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : search the second TLV (06) (CR is set) + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)6,(byte)1)==TLV_FOUND_CR_SET) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : verify that this TLV is the the current TLV + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)6,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.getValueLength()==0x0E)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : try to find a bad tag + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.findTLV((byte)3,(byte)1)==TLV_NOT_FOUND)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : search a bad tag (03) and try to get the length of the current TLV + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)3,(byte)1)==TLV_NOT_FOUND) + &&(envHdlr.getValueLength()==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : search the tag 02 with a bad occurence (3) + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)2,(byte)3)==TLV_NOT_FOUND) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : search the tag 02 with a bad occurence (3) and try to get the length + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)2,(byte)3)==TLV_NOT_FOUND) + &&(envHdlr.getValueLength()==0)) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : search the occurence 02 of the tag 02 + testCaseNb = (byte) 10 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)2,(byte)2)==TLV_FOUND_CR_NOT_SET) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 10 : + // -------------------------------------------- + // Test Case 11 : search the occurence 01 of the tag 04 + testCaseNb = (byte) 11 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)4,(byte)1)==TLV_FOUND_CR_NOT_SET) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 11 : + // -------------------------------------------- + // Test Case 12 : search the occurence 01 of the tag 86 + testCaseNb = (byte) 12 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)0x86,(byte)1)==TLV_FOUND_CR_SET) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 12 : + // -------------------------------------------- + // Test Case 13 : search the occurence 01 of the tag 84 + testCaseNb = (byte) 13 ; + + bRes = false ; + try { + if(envHdlr.findTLV((byte)0x84,(byte)1)==TLV_FOUND_CR_NOT_SET) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/Test_Api_2_Enh_Find.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/Test_Api_2_Enh_Find.java new file mode 100644 index 0000000000000000000000000000000000000000..98ba1e3f2cb4a548fa59c2e48c0ddeb41c90d07c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/Test_Api_2_Enh_Find.java @@ -0,0 +1,122 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Find_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_find; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Find + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Find extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_find"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Find() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)13; i++ ) + { + // 1: Send Unrecognized Envelope with Tag 82,86,8B,02 and 04. + response = test.sendApdu( "80 C2 00 00 33" + + "01 31" + + "82 02 83 81" + + "86 0E" + + "01020304 05060708 090A0B0C 0D0E" + + "8B 04" + + "01020304" + + "02 06" + + "0708090A 0B0C" + + "04 0D" + + "01020304 05060708 090A0B0C 0D"); + if(i == 0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b6794e738851fd374d6e5c46febf60928fa792c8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_find.Api_2_Enh_Find_1 +uicc.test.toolkit.api_2_enh_find +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/javacard/api_2_enh_find.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/javacard/api_2_enh_find.cap new file mode 100644 index 0000000000000000000000000000000000000000..76a19e38c2c851091c2b56ef978097667025969c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_find/javacard/api_2_enh_find.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/Api_2_Enh_Gcap_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/Api_2_Enh_Gcap_1.java new file mode 100644 index 0000000000000000000000000000000000000000..2b7bfbe8341d8fbc7ea72450f081f5feacb1c0ea --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/Api_2_Enh_Gcap_1.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gcap_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gcap; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_enh_gcap + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gcap_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gcap_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gcap_1 thisApplet = new Api_2_Enh_Gcap_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + //register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes; + + // results of methods + short sLength = 0; + short sCapacity = 0; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // Get length of the BER TLV + bRes = false; + testCaseNb++; + try { + sLength = envHdlr.getLength(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + // get capacity of the handler + try { + sCapacity = envHdlr.getCapacity(); + bRes &= true; + } + catch (Exception e) { + bRes &= false; + } + + // Capacity must be greater than length of BER TLV + if (sCapacity < sLength) + { + bRes &= false; + } + else + { + bRes &= true; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/Test_Api_2_Enh_Gcap.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/Test_Api_2_Enh_Gcap.java new file mode 100644 index 0000000000000000000000000000000000000000..c5ba48a9761689aa54d6723a0ba2296282149c94 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/Test_Api_2_Enh_Gcap.java @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gcap.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gcap; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gcap + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gcap extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gcap"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gcap() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 1: Send Unrecognized Envelope to trig the Applet + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2af71aca6287be37fbcb22aff47127faade1cbd9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gcap.Api_2_Enh_Gcap_1 +uicc.test.toolkit.api_2_enh_gcap +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/javacard/api_2_enh_gcap.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/javacard/api_2_enh_gcap.cap new file mode 100644 index 0000000000000000000000000000000000000000..9d478e2f45681cba10bb5b6d7ca44d6c7ab9345e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcap/javacard/api_2_enh_gcap.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/Api_2_Enh_Gcid_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/Api_2_Enh_Gcid_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e6622f03cad97d48103072e9ddd99813e32c6667 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/Api_2_Enh_Gcid_1.java @@ -0,0 +1,202 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gcid_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gcid; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.test.util.*; + +/** + * Test Area : uicc.test.toolkit.api_2_enh_gcid + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gcid_1 extends TestToolkitApplet +{ + private final byte[] ADDRESS = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + private final byte[] BEARER_DESC = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + private static byte[] menuEntry = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'1'}; + // Number of tests + byte testCaseNb = (byte) 0x00; + private static final byte DEV_ID_ME = (byte)0x82; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gcid_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gcid_1 thisApplet = new Api_2_Enh_Gcid_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Set Event Download Channel Status as an activation event for the applet + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS); + // Set Unrecognized Envelope as an activation event for the applet + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0,(short)menuEntry.length,(byte)0,false,(byte)0,(short)0); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes; + // Miscelaneous + byte bChannelNb; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + if (event == EVENT_MENU_SELECTION) + { + // The Applet open all the 7 channels by sending 7 Open Channel commands + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_ME); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + for (bChannelNb = 0; bChannelNb < 7; bChannelNb++) + { + proHdlr.send() ; + } + } + else + { + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : getChannelIdentifier(), normal execution + testCaseNb = (byte) 1 ; + bRes = false ; + try { + if (envHdlr.getChannelIdentifier() == 0x01) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : Twice calling of getChannelIdentifier() with 2 + // Channel Status TLV + testCaseNb = (byte) 2 ; + bRes = false ; + try { + if (envHdlr.getChannelIdentifier() == 0x04) + if (envHdlr.getChannelIdentifier() == 0x04) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : Channel Status TLV is selected after the call + // of getChannelIdentifier() + testCaseNb = (byte) 3 ; + bRes = false ; + try { + envHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte) 0x01); + if (envHdlr.getChannelIdentifier() == + envHdlr.getValueByte((byte)0x00)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : getChannelIdentifier() with no Channel Status TLV + testCaseNb = (byte) 4 ; + bRes = false ; + try { + envHdlr.getChannelIdentifier(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : getChannelIdentifier() on a clased channel + testCaseNb = (byte) 5 ; + bRes = false ; + try { + if (envHdlr.getChannelIdentifier() == 0x06) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 5 : getChannelIdentifier() with an empty Channel Status TLV + testCaseNb = (byte) 6 ; + bRes = false ; + try { + envHdlr.getChannelIdentifier(); + bRes = false; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } // End switch + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/Test_Api_2_Enh_Gcid.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/Test_Api_2_Enh_Gcid.java new file mode 100644 index 0000000000000000000000000000000000000000..4419caf5b2c24c5764df54c8f8efceb50a1974b1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/Test_Api_2_Enh_Gcid.java @@ -0,0 +1,176 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gcid.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gcid; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gcid + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gcid extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gcid"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gcid() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession("1FF0FFFF 00FF0000 010000 1F40"); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // Position and Id of the first item + "07" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession("1FF0FFFF 00FF0000 010000 1F40"); + + // 0: Send Envelope Menu Selection with Item Identifier set to 01 + // to open 7 channels + response = test.envelopeMenuSelection("10 01 01",""); + + // Fetch the first OPEN CHANNEL proactive command + response = test.fetch("1C"); + result = response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028100" + + "35040100 00003902 0080"); + + // Fetch the second OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028200" + + "35040100 00003902 0080"); + + // Fetch the third OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028300" + + "35040100 00003902 0080"); + + // Fetch the fourth OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028400" + + "35040100 00003902 0080"); + + // Fetch the fifth OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028500" + + "35040100 00003902 0080"); + + // Fetch the sixth OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028600" + + "35040100 00003902 0080"); + + // Fetch the seventh OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + test.terminalResponse("81030140 01820282 81030100 38028700" + + "35040100 00003902 0080"); + + // 1 : Trig the applet with EventDownloadChannelStatus with channel status value = 0x8100 + test.envelopeEventDownloadChannelStatus("38028100"); + + // 2 : Trig the applet with EventDownloadChannelStatus with channel status value = 0x8400 and 0x8500 + test.envelopeEventDownloadChannelStatus("38028400 38028500"); + + // 3 : Send envelope EvenDownloadChannelStatus with channel status value = 0x0605 + test.envelopeEventDownloadChannelStatus("38020605"); + + // 4 : Send unrecognized envelope with no channel status TLV + test.unrecognizedEnvelope(); + + // 5 : Send envelope EvenDownloadChannelStatus with channel status value = 0x0600 + test.envelopeEventDownloadChannelStatus("38020600"); + + // 5 : Send unrecognized envelope with channel status TLV length set to 0 + test.sendApdu("80C20000 08010682 02828138 00"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..bf759af3ad3edd058c32549f57564017752f88b2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gcid.Api_2_Enh_Gcid_1 +uicc.test.toolkit.api_2_enh_gcid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/javacard/api_2_enh_gcid.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/javacard/api_2_enh_gcid.cap new file mode 100644 index 0000000000000000000000000000000000000000..bcf5697bd7a183978577b3ffce85bbcf42630b39 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcid/javacard/api_2_enh_gcid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/Api_2_Enh_Gcst_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/Api_2_Enh_Gcst_1.java new file mode 100644 index 0000000000000000000000000000000000000000..213ece745ccdf0d59dafa897088df921c32e94a4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/Api_2_Enh_Gcst_1.java @@ -0,0 +1,242 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gcst_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gcst; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gcst + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gcst_1 extends TestToolkitApplet +{ + private final byte[] ADDRESS = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + private final byte[] BEARER_DESC = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + private static byte[] menuEntry = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'1'}; + private final byte[] DisplayText = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T',(byte)'1'}; + + // Number of tests + byte testCaseNb = (byte) 0x00; + private static final byte DEV_ID_ME = (byte)0x82; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gcst_1 () + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gcst_1 thisApplet = new Api_2_Enh_Gcst_1 (); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Set Event Download Channel Status as an activation event for the applet + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS); + // Set Unrecognized Envelope as an activation event for the applet + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + //register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(menuEntry,(short)0,(short)menuEntry.length,(byte)0,false,(byte)0,(short)0); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes; + // Miscelaneous + byte bChannelNb; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + if (event == EVENT_MENU_SELECTION) + { + // The Applet send an open channel proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_ME); + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + } + else + { + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : getChannelStatus(), with no Channel Status TLV + testCaseNb = (byte) 1 ; + bRes = false ; + try { + envHdlr.getChannelStatus((byte)0x01); + } + catch (ToolkitException e) + { + if(e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + else + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : getChannelStatus(), with no wrong identifier + testCaseNb = (byte) 2 ; + bRes = false ; + try { + envHdlr.getChannelStatus((byte)0x01); + } + catch (ToolkitException e) + { + if(e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + else + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : Channel Status TLV with length set to 00 + testCaseNb = (byte) 3 ; + bRes = false ; + try { + envHdlr.getChannelStatus((byte)0x01); + } + catch (ToolkitException e) + { + if(e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + else + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : getChannelStatus() with length set to 01 + testCaseNb = (byte) 4 ; + bRes = false ; + try { + envHdlr.getChannelStatus((byte)0x01); + } + catch (ToolkitException e) + { + if(e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true; + else + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : getChannelStatus() value + testCaseNb = (byte) 5 ; + bRes = false ; + try { + if(envHdlr.getChannelStatus((byte)0x01)== (short)0x8100) + bRes =true; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : getChannelStatus() with two TLV + testCaseNb = (byte) 6 ; + bRes = false ; + try { + if(envHdlr.getChannelStatus((byte)0x01)== (short)0x8100) + bRes =true; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : Channel Status TLV is the currently selected TLV + testCaseNb = (byte) 7 ; + bRes = false ; + try { + // Find the Device ID TLV anc compare to the result of getChannelStatus + envHdlr.findTLV(DEV_ID_TERMINAL,(byte)0x01); // Set the current TLV to Device Id TLV + short ChannelStatusValue = envHdlr.getChannelStatus((byte)0x01); + if((envHdlr.getChannelStatus((byte)0x01)== envHdlr.getValueShort((short)0)) + && (ChannelStatusValue== (short)0x8100)) + bRes = true; + else + bRes = false; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : Get channel Status value after proactive command + testCaseNb = (byte) 8 ; + bRes = false ; + try { + short ChannelStatusValue = envHdlr.getChannelStatus((byte)0x01); + (ProactiveHandlerSystem.getTheHandler()).initDisplayText((byte)00,(byte)0xF6,DisplayText,(short)0,(short)DisplayText.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + if((envHdlr.getChannelStatus((byte)0x01)) == ChannelStatusValue) + bRes = true; + else + bRes = false; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } // End switch + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/Test_Api_2_Enh_Gcst.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/Test_Api_2_Enh_Gcst.java new file mode 100644 index 0000000000000000000000000000000000000000..c608ec187a862ee853e6b9bf8275c5b8bd49e609 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/Test_Api_2_Enh_Gcst.java @@ -0,0 +1,144 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gcst.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gcst; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gcst + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gcst extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gcst"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gcst() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // Position and Id of the first item + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession("1FF0FFFF 00FF0000 010000 1F"); + + // 0: Send Envelope Menu Selection with Item Identifier set to 01 + // to open a channel + response = test.envelopeMenuSelection("10 01 01",""); + + // Fetch the first OPEN CHANNEL proactive command + response = test.fetch("1C"); + result = response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + test.terminalResponse("81030140 01820282 81030100 38028100" + + "35040100 00003902 0080"); + + // 1 : Trig the applet with Unrecognized Envelope with no Channel Status TLV + test.sendApdu("80C20000 09010799 010A8202 8281"); + + // 2 : Trig the applet with Unrecognized envelope with the expected Identifier not present + test.sendApdu("80C20000 0D010B99 010A8202 82813802 8200"); + + // 3 : Send an Unrecognized envelope with channel status TLV length set to 0 + test.sendApdu("80C20000 0B010999 010A8202 82813800"); + + // 4 : Send an Unrecognized Envelope with channel length set to 01 + test.sendApdu("80C20000 0C010A99 010A8202 82813801 81"); + + // 5 : Send envelope EvenDownloadChannelStatus with channel status value set to 0x8100 + test.envelopeEventDownloadChannelStatus("38028100"); + + // 6 : Send envelope EvenDownloadChannelStatus with two TLV + test.envelopeEventDownloadChannelStatus("38028100 38028101"); + + // 7 : Channel Status TLV is the curently selected TLV + test.envelopeEventDownloadChannelStatus("38028100"); + + // 8 : Get channel status value after proactive command + test.envelopeEventDownloadChannelStatus("38028100"); + // Fetch the display text proactive command + response = test.fetch("15"); + result &= response.checkData("D0138103 01210082 0281028D 08F64150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check result */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + return result; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c46684147973cda163b471dae22a4d8da019b724 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gcst.Api_2_Enh_Gcst_1 +uicc.test.toolkit.api_2_enh_gcst +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/javacard/Api_2_Enh_Gcst.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/javacard/Api_2_Enh_Gcst.cap new file mode 100644 index 0000000000000000000000000000000000000000..fb8eab407b31ac77ac9b6a3d6f77d714d0822a61 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gcst/javacard/Api_2_Enh_Gcst.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/Api_2_Enh_Giid_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/Api_2_Enh_Giid_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5bc47d53cd9660432600905fd859584bad88b2c7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/Api_2_Enh_Giid_1.java @@ -0,0 +1,233 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Giid_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.toolkit.api_2_enh_giid; + +import uicc.toolkit.*; +import uicc.test.util.*;; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Giid + * + * @version 0.0.1 - 28 oct. 2004 + * @author 3GPP T3 SWG API + */ + +public class Api_2_Enh_Giid_1 extends TestToolkitApplet +{ + + /** Registry entry concerning applet instance */ + private static byte[] displayString = {(byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O'}; + private static byte[] Menu1 = {(byte)'M', (byte)'E', (byte)'N', (byte)'U', (byte)'1'}; + private static byte[] Menu2 = {(byte)'M', (byte)'E', (byte)'N', (byte)'U', (byte)'2'}; + private static byte[] Menu3 = {(byte)'M', (byte)'E', (byte)'N', (byte)'U', (byte)'3'}; + private static byte[] Menu4 = {(byte)'M', (byte)'E', (byte)'N', (byte)'U', (byte)'4'}; + private static byte[] Menu66 = {(byte)'M', (byte)'E', (byte)'N', (byte)'U', (byte)'6', (byte)'6'}; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + private static final byte DCS_8_BIT_DATA = (byte) 0x04; + + + /** + * Constructor of the applet + */ + public Api_2_Enh_Giid_1() + { + + + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Giid_1 thisApplet = new Api_2_Enh_Giid_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(Menu1, (short) 0, (short) Menu1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(Menu2, (short) 0, (short) Menu2.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(Menu3, (short) 0, (short) Menu3.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(Menu4, (short) 0, (short) Menu4.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(Menu66, (short) 0, (short) Menu66.length, (byte) 0, false, (byte) 0, (short) 0); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + switch ( testCaseNb ) { + + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : get item identifier value is 03 + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if (envHdlr.getItemIdentifier() == (byte) 0x03) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : Receive envelope with two item identifier TLV with first value 02 and second 01 + // method must return 02 + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + if (envHdlr.getItemIdentifier() == (byte) 0x02) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : Receive envelope with two item identifier TLV with first value 04 and second 01, call twice the method getItemIdentifier + // method must always return 04 + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + if ((envHdlr.getItemIdentifier() == (byte) 0x04) && (envHdlr.getItemIdentifier() == (byte) 0x04) ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : Receive envelope with item identifier TLV and value of 66. FindTLV with TAG 02. getItemIdentifier and after getValueByte with offset 0 + // getItemIdentifier returned value = getValueByte returned value + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + envHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1); + if ( envHdlr.getItemIdentifier() == envHdlr.getValueByte((short)0) ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : Receive envelope without item identifier TLV and getItemIdentifier + // getItemIdentifier must throw ToolkitException (UNAVAILABLE_ELEMENT) + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + envHdlr.getItemIdentifier(); + bRes = false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT ) + bRes = true; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : Receive envelope with item identifier TLV (66), send proactive command. Then getItemIdentifier + // method must return 66 + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + if (envHdlr.getItemIdentifier() == (byte) 0x66) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : Receive envelope with item identifier TLV but without item number, send proactive command. + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + if (envHdlr.getItemIdentifier() == (byte) 0x00) + bRes = false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + break; + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/Test_Api_2_Enh_Giid.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/Test_Api_2_Enh_Giid.java new file mode 100644 index 0000000000000000000000000000000000000000..93a4e21f9237cb7c47ba30e82ef5207ff45d23a4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/Test_Api_2_Enh_Giid.java @@ -0,0 +1,134 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Giid.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_giid; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Giid + * + * @version 0.0.1 - 28 oct. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Giid extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/Api_2_Enh_Giid"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Giid() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8012" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "05" + // V Maximum number of menu entries + "0101" + // Position and Id of the first item + "0202" + // Position and Id of the first item + "0303" + // Position and Id of the first item + "0404" + // Position and Id of the first item + "0566" + // Position and Id of the first item + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 1: Send Envelope Menu Selection with Item Identifier set to 03 + response = test.envelopeMenuSelection("100103",""); + + // 2 : Send Envelope Menu Selection with two Item Identifier TLV + response = test.envelopeMenuSelection("10010210 0101",""); + + // 3 : Send Envelope Menu Selection with two Item Identifier TLV + response = test.envelopeMenuSelection("90010410 0101",""); + + // 4 : Send Envelope Menu Selection Item Identifier set to 66 + response = test.envelopeMenuSelection("900166",""); + + // 5 : Send Unrecognized Envelope + test.unrecognizedEnvelope(); + + // 6 : Send Envelope Menu Selection with item identifier set to 66 + response = test.envelopeMenuSelection("100166",""); + + // Fetch the proactive command + response = test.fetch("13"); + result = response.checkData("D0118103 01218082 0281028D 06044845" + + "4C4C4F"); + test.terminalResponse("81030121 80020282 81030100"); + + // 7 : Send Unrecognized envelope with item Identifier TLV but without Item Number + response = test.sendApdu("80C20000 08010682 02018110 00"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "07CCCCCC CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..14af6382cd056965df1a63564c9c087f70f9c8f5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_giid.Api_2_Enh_Giid_1 +uicc.test.toolkit.api_2_enh_giid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/javacard/api_2_enh_giid.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/javacard/api_2_enh_giid.cap new file mode 100644 index 0000000000000000000000000000000000000000..59d53b51e19b233ec493923f48a8033e87f7a7ac Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_giid/javacard/api_2_enh_giid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/Api_2_Enh_Glen_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/Api_2_Enh_Glen_1.java new file mode 100644 index 0000000000000000000000000000000000000000..267742d8be35b9b5ab173ce47ee5b6beb441c269 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/Api_2_Enh_Glen_1.java @@ -0,0 +1,140 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Glen_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- + +package uicc.test.toolkit.api_2_enh_glen; + +import uicc.toolkit.*; +import uicc.test.util.*;; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + + +/** +* Test Area : uicc.test.toolkit.Api_2_Enh_Glen +* +* @version 0.0.1 - 28 oct. 2004 +* @author 3GPP T3 SWG API +*/ + +public class Api_2_Enh_Glen_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Glen_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Glen_1 thisApplet = new Api_2_Enh_Glen_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if (envHdlr.getLength()==0x31 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + if (envHdlr.getLength()==0x7F ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + if (envHdlr.getLength()==0x80 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + if (envHdlr.getLength()==0xFC ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/Test_Api_2_Enh_Glen.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/Test_Api_2_Enh_Glen.java new file mode 100644 index 0000000000000000000000000000000000000000..dfab5656ad5a1c89825812c6bbc7ef8dc691792a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/Test_Api_2_Enh_Glen.java @@ -0,0 +1,168 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Glen.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_glen; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Glen + * + * @version 0.0.1 - 2 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Glen extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_glen"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Glen() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH,CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // 1: Send Unrecognized Envelope with BER TLV Length set to 31 + response = test.sendApdu( "80 C2 00 00 33" + + "01 31" + + "82 02 83 81" + + "FF 2B" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B"); + + result = response.checkSw("90 00"); + + // 2 : Send Unrecognized Envelope with BER TLV Length set to 7F + response = test.sendApdu( "80 C2 00 00 81" + + "01 7F" + + "82 02 83 81" + + "FF 79" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 09"); + result &= response.checkSw("9000"); + + // 2 : Send Unrecognized Envelope with BER TLV Length set to 80 + response = test.sendApdu( "80 C2 00 00 83" + + "01 81 80" + + "82 02 83 81" + + "FF 7A" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A"); + result &= response.checkSw("9000"); + + + // 3 : Send Unrecognized Envelope with BER TLV Length set to FC + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "FF 81 F5" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05"); + result &= response.checkSw("90 00"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "04CCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3edbb880685c2d3d7a673b1500887c1926a7c05b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_glen.Api_2_Enh_Glen_1 +uicc.test.toolkit.api_2_enh_glen +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/javacard/Api_2_Enh_Glen.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/javacard/Api_2_Enh_Glen.cap new file mode 100644 index 0000000000000000000000000000000000000000..649558eea61d033ebe1019f7eccf6c0b4986dbba Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_glen/javacard/Api_2_Enh_Glen.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/Api_2_Enh_Gtsz_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/Api_2_Enh_Gtsz_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1db8c50eee6ad70ef2c24fbee186fedd024a9d36 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/Api_2_Enh_Gtsz_1.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gtsz_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gtsz; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_enh_gtsz + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gtsz_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + private final byte[] DisplayText = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T',(byte)'1'}; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gtsz_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gtsz_1 thisApplet = new Api_2_Enh_Gtsz_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // -------------------------------------------- + // Test Case 1 : GetSize() after applet triggering + testCaseNb = (byte) 1 ; + bRes = false ; + try { + if(envHdlr.getSize() == (byte)0x33) + bRes = true; + else + bRes = false; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : Getsize() after proactive command + + (ProactiveHandlerSystem.getTheHandler()).initDisplayText((byte)00,(byte)0xF6,DisplayText,(short)0,(short)DisplayText.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + + testCaseNb = (byte) 2 ; + bRes = false ; + try { + if(envHdlr.getSize() == (byte)0x33) + bRes = true; + else + bRes = false; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/Test_Api_2_Enh_Gtsz.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/Test_Api_2_Enh_Gtsz.java new file mode 100644 index 0000000000000000000000000000000000000000..5aa63ac965fd6b9bff4c08050ebba3c8d342cce1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/Test_Api_2_Enh_Gtsz.java @@ -0,0 +1,118 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gtsz.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gtsz; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gtsz + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gtsz extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/Api_2_Enh_Gtsz"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gtsz() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + /* 1: Send Unrecognized Envelope with Tag 02, length 02 + Tag 06, length 06 + Tag 33, length C8. + */ + response = test.sendApdu( "80 C2 00 00 33" + + "01 31 " + + "02 02 83 81" + + "33 2B" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B"); + response = test.fetch("15"); + result = response.checkData("D0138103 01210082 0281028D 08F64150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "02CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9e5eac20d1e127a8bbac8e21284e63242b93e2f5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gtsz.Api_2_Enh_Gtsz_1 +uicc.test.toolkit.api_2_enh_gtsz +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/javacard/api_2_enh_gtsz.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/javacard/api_2_enh_gtsz.cap new file mode 100644 index 0000000000000000000000000000000000000000..f2af2e498015656b1cf79779d6e0b75e57e365b5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gtsz/javacard/api_2_enh_gtsz.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/Api_2_Enh_Gttg_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/Api_2_Enh_Gttg_1.java new file mode 100644 index 0000000000000000000000000000000000000000..392552df5a0a00ef926ab18dbf3adab72bc8939b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/Api_2_Enh_Gttg_1.java @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gttg_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gttg; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gttg + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gttg_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + private final byte[] DisplayText = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T',(byte)'1'}; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gttg_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gttg_1 thisApplet = new Api_2_Enh_Gttg_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // -------------------------------------------- + // Test Case 1 : GetTag() after applet triggering + testCaseNb = (byte) 1 ; + bRes = false ; + try { + if(envHdlr.getTag() == (byte)0x01) + bRes = true; + else + bRes = false; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : GetTag() after proactive command + + (ProactiveHandlerSystem.getTheHandler()).initDisplayText((byte)00,(byte)0xF6,DisplayText,(short)0,(short)DisplayText.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + + testCaseNb = (byte) 2 ; + bRes = false ; + try { + if(envHdlr.getTag() == (byte)0x01) + bRes = true; + else + bRes = false; + } + catch (ToolkitException e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/Test_Api_2_Enh_Gttg.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/Test_Api_2_Enh_Gttg.java new file mode 100644 index 0000000000000000000000000000000000000000..9875d57459f65dbc388468b68446f7ccd0acf7cd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/Test_Api_2_Enh_Gttg.java @@ -0,0 +1,118 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gttg.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gttg; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gttg + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gttg extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gttg"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gttg() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + /* 1: Send Unrecognized Envelope with Tag 02, length 02 + Tag 33, length 2B. + */ + response = test.sendApdu( "80 C2 00 00 33" + + "01 31 " + + "02 02 83 81" + + "33 2B" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B"); + + response = test.fetch("15"); + result = response.checkData("D0138103 01210082 0281028D 08F64150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "02CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9be6f2bc7bb71ec6598e30f896ec79d42f104484 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gttg.Api_2_Enh_Gttg_1 +uicc.test.toolkit.api_2_enh_gttg +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/javacard/api_2_enh_gttg.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/javacard/api_2_enh_gttg.cap new file mode 100644 index 0000000000000000000000000000000000000000..aafd77975981ce812babd33909a7995a067ea1eb Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gttg/javacard/api_2_enh_gttg.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/Api_2_Enh_Gvby_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/Api_2_Enh_Gvby_1.java new file mode 100644 index 0000000000000000000000000000000000000000..51793979895560be441b4a08180b1e961ee09d8e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/Api_2_Enh_Gvby_1.java @@ -0,0 +1,213 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gvby.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gvby; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + + +/** + * Test Area : uicc.test.toolkit.api_2_enh_gvby + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gvby_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gvby_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gvby_1 thisApplet = new Api_2_Enh_Gvby_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : use the method getValueByte with the offset parameter = 0 + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if (envHdlr.getValueByte((short)0)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the method getValueByte() with the offset parameter out of the tlv + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)3)==0x00 )) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : normal execution of the getValueByte() methodon TAG 02 and offset 1 + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)1)==(byte)0x81 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : normal execution of the getValueByte() method on TAG 02 and offset 0 + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)0)==(byte)0x83 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : normal execution of the getValueByte() method on TAG 33 and offset 7E + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)0x007E)==(byte)0x7F )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : normal execution of the getValueByte() method on TAG 33 and offset 80 + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)0x0080)==(byte)0x81 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : normal execution of the getValueByte() method on TAG 33 and offset 7F + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)0x007F)==(byte)0x80 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : normal execution of the getValueByte() method on TAG B3 and offset C7 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + if ((envHdlr.findTLV((byte)0xB3,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueByte((short)0x00C7)==(byte)0xC8 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/Test_Api_2_Enh_Gvby.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/Test_Api_2_Enh_Gvby.java new file mode 100644 index 0000000000000000000000000000000000000000..99798bffaa7cafcb845a5003ecc226826165cabd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/Test_Api_2_Enh_Gvby.java @@ -0,0 +1,131 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gvby.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gvby; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gvby + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gvby extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gvby"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gvby() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + for(byte i = 0; i <= (byte)8; i++ ) + { + /* 1: Send Unrecognized Envelope with Tag 02, length 02 + Tag 06, length 06 + Tag 33, length C8. + */ + response = test.sendApdu( "80 C2 00 00 DA" + + "01 81 D7" + + "02 02 83 81" + + "06 06" + + "01020304 0506" + + "33 81 C8" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 "); + if(i == 0) + result = response.checkSw("90 00"); + else + result &= response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..56b7a51cbfc4017f6e7309736473522ec1d6d5e5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gvby.Api_2_Enh_Gvby_1 +uicc.test.toolkit.api_2_enh_gvby +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/javacard/api_2_enh_gvby.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/javacard/api_2_enh_gvby.cap new file mode 100644 index 0000000000000000000000000000000000000000..a45713b1e18749c680337ebfa10f05a27fd6ff36 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvby/javacard/api_2_enh_gvby.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/Api_2_Enh_Gvle_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/Api_2_Enh_Gvle_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f58001db7cdfc8c257b13783a5e8e9d6e47deb35 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/Api_2_Enh_Gvle_1.java @@ -0,0 +1,141 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gvle_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gvle; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gvle + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gvle_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gvle_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gvle_1 thisApplet = new Api_2_Enh_Gvle_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short arg0) throws ToolkitException + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use the getValueLength method without current TLV + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + short returned_value = envHdlr.getValueLength(); + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : search the TAG 02 and use the method getValueLength =02 + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.getValueLength()==0x0002)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : search the TAG 0B and use the method getValueLength =0x24 + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)0x0B,(byte)1)==TLV_FOUND_CR_SET) + &&(envHdlr.getValueLength()==0x0024)) + bRes = true; + } + catch (ToolkitException e) { + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : search the TAG 0x33 and use the method getValueLength =0x00C8 + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + if((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueLength()==0x00C8)) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } + + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/Test_Api_2_Enh_Gvle.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/Test_Api_2_Enh_Gvle.java new file mode 100644 index 0000000000000000000000000000000000000000..a413cf1f85b9b2991f630cf49448a0d3a13dccd0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/Test_Api_2_Enh_Gvle.java @@ -0,0 +1,140 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gvle.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gvle; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gvle + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gvle extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gvle"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gvle() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + for(byte i = 0; i <= (byte)4; i++ ) + { + /* 1: Send Unrecognized Envelope with Tag 82, length 02 + Tag 06, length 05 + Tag 0B, length 24 + Tag 33, length C8. + */ + response = test.sendApdu( "80 C2 00 00 FF" + + "01 81 FC" + + "82 02 83 81" + + "06 05" + + "01020304 05" + + "8B 24" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304" + + "33 81 C8" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "01020304 05060708"); + + if(i == 0) + result = response.checkSw("9000"); + else + result &= response.checkSw("9000"); + + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "04CCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7b12adde347c8a05c2b38729d59c649decefa6da --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gvle.Api_2_Enh_Gvle_1 +uicc.test.toolkit.api_2_enh_gvle +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/javacard/api_2_enh_gvle.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/javacard/api_2_enh_gvle.cap new file mode 100644 index 0000000000000000000000000000000000000000..427569ac17dc75b833b3b484c259296eb347690c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvle/javacard/api_2_enh_gvle.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/Api_2_Enh_Gvsh_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/Api_2_Enh_Gvsh_1.java new file mode 100644 index 0000000000000000000000000000000000000000..840c53d708df07c2a3430bde7440bcdfedcea105 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/Api_2_Enh_Gvsh_1.java @@ -0,0 +1,215 @@ +//----------------------------------------------------------------------------- +//Api_2_Enh_Gvsh_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gvsh; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_enh_gvsh + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Api_2_Enh_Gvsh_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Enh_Gvsh_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Enh_Gvsh_1 thisApplet = new Api_2_Enh_Gvsh_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : use the method getValueShort with the offset parameter = 0 + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + if (envHdlr.getValueShort((short)0)==0) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : use the method getValueByte() with the offset parameter out of the tlv + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)2)==(short)0x8381 )) + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : normal execution of the getValueByte() method on TAG 02 and offset 0 + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)2,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)0)==(short)0x8381 )) + bRes = true; + else + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : normal execution of the getValueByte() method on TAG 06 and offset 01 + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x06,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)1)==(short)0x1122 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : normal execution of the getValueByte() method on TAG 33 and offset 7E + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)0x007E)==(short)0x7F80 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : normal execution of the getValueByte() method on TAG 33 and offset 80 + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)0x0080)==(short)0x8182 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : normal execution of the getValueByte() method on TAG 33 and offset 7F + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + if ((envHdlr.findTLV((byte)0x33,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)0x007F)==(short)0x8081 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : normal execution of the getValueByte() method on TAG B3 and offset C7 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + if ((envHdlr.findTLV((byte)0xB3,(byte)1)==TLV_FOUND_CR_NOT_SET) + &&(envHdlr.getValueShort((short)0x00C7)==(short)0xC8C9 )) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/Test_Api_2_Enh_Gvsh.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/Test_Api_2_Enh_Gvsh.java new file mode 100644 index 0000000000000000000000000000000000000000..9cf80d2e38d9a606b0003e47e46da81d17069348 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/Test_Api_2_Enh_Gvsh.java @@ -0,0 +1,134 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Enh_Gvsh.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_enh_gvsh; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gvsh + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Enh_Gvsh extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_enh_gvsh"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Enh_Gvsh() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + for(byte i = 0; i <= (byte)7; i++ ) + { + /* 1: Send Unrecognized Envelope with Tag 02, length 02 + Tag 06, length 06 + Tag 33, length C8. + */ + response = test.sendApdu( "80 C2 00 00 DF" + + "01 81 DC" + + "02 02 83 81" + + "06 06" + + "81112233 44F5" + + "02 02 22 44" + + "33 81 C9" + + "01020304 05060708 090A0B 0C0D0E0F10" + + "11121314 15161718 191A1B 1C1D1E1F20" + + "21222324 25262728 292A2B 2C2D2E2F30" + + "31323334 35363738 393A3B 3C3D3E3F40" + + "41424344 45464748 494A4B 4C4D4E4F50" + + "51525354 55565758 595A5B 5C5D5E5F60" + + "61626364 65666768 696A6B 6C6D6E6F70" + + "71727374 75767778 797A7B 7C7D7E7F80" + + "81828384 85868788 898A8B 8C8D8E8F90" + + "91929394 95969798 999A9B 9C9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAAB ACADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABB BCBDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9"); + if(i == 0) + result = response.checkSw("9000"); + else + result &= response.checkSw("9000"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4bf560a1276131c75ca48149081eb0a2ae7cfed9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_enh_gvsh.Api_2_Enh_Gvsh_1 +uicc.test.toolkit.api_2_enh_gvsh +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/javacard/api_2_enh_gvsh.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/javacard/api_2_enh_gvsh.cap new file mode 100644 index 0000000000000000000000000000000000000000..17a82f96ca069db6165e156945227b7e6d7d5a82 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_enh_gvsh/javacard/api_2_enh_gvsh.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/Api_2_Erh_Apda_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/Api_2_Erh_Apda_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..9b26228e91a3a292a8bcc0bdad37d4155fc55aff --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/Api_2_Erh_Apda_Bss_1.java @@ -0,0 +1,409 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Apda_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_apda_bss; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_apda_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Apda_Bss_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] buffer5 = new byte[5]; + private byte[] buffer = new byte[8] ; + private byte[] copyBuffer = new byte[32] ; + private byte[] compareBuffer = new byte[32] ; + private byte[] large_buffer; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Apda_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Apda_Bss_1 thisApplet = new Api_2_Erh_Apda_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + short offset = 0 ; + short length = 0 ; + + // -------------------------------------------- + // Test Case 1 : Null buffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + EnvRespHdlr.appendTLV((byte) 1, (byte) 1); + + try { + offset = (short)0 ; + length = (short)1 ; + + EnvRespHdlr.appendArray(null, offset, length) ; + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : offset>buffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + offset = (short)5 ; + length = (short)1 ; + + EnvRespHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + offset = (short)-1 ; + length = (short)1 ; + + EnvRespHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : length>buffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + length = (short)6 ; + + EnvRespHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : offset + length>buffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + offset = (short)3 ; + length = (short)3 ; + + EnvRespHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : length < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + length = (short)-1 ; + + EnvRespHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : handler overflow + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + length = (short)(EnvRespHdlr.getCapacity() + 1) ; + large_buffer = new byte[length]; + Util.arrayFillNonAtomic(large_buffer,(short)0,(short)large_buffer.length,(byte)0); + EnvRespHdlr.appendArray(large_buffer, offset, length) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : A successfull append does not modify the current TLV + testCaseNb = (byte) 8 ; + bRes = false ; + + + + try { + + EnvRespHdlr.clear(); + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + + // Initialise buffer + for (short i=0; i<(short)buffer.length; i++) + buffer[i] = (byte) ((byte)0xFF-i) ; + + // Select Command Details TLV + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append buffer + offset = (short)0 ; + length = (short)buffer.length ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==(short)3) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Successfull call + testCaseNb = (byte) 9 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer.length; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + compareBuffer[i] = (byte)((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + } + + try { + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append buffer + offset = (short)0 ; + length = (short)buffer.length ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // Copy the handler + offset = (short) 0 ; + length = (short) 8 ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset,compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer.length; i++) + { + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + if (i>=(byte)2) + compareBuffer[(short)(i+6)] = (byte)i ; // FF FE FD FC FB FA F9 F8 02 03 04 05 06 07 + } + + try { + + // Append buffer + offset = (short)2 ; + length = (short)6 ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)14 ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + testCaseNb = (byte) 11 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer.length; i++) + { + buffer[i] = (byte) ((i+1)*0x11) ; // 11 22 33 44 55 66 77 88 + if (i>=(byte)2) + compareBuffer[(short)(i+12)] = (byte)((i+1)*0x11) ; // FF FE FD FC FB FA F9 F8 02 03 04 05 06 07 33 44 55 66 + } + + try { + + // Append buffer + offset = (short)2 ; + length = (short)4 ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)18 ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset,compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 12 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append buffer + try { + offset = (short)2 ; + length = (short)4 ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/Test_Api_2_Erh_Apda_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/Test_Api_2_Erh_Apda_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..41b39013602f30c8d56ffc61f2624c3cf6776e61 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/Test_Api_2_Erh_Apda_Bss.java @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Apda_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_apda_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_apda_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Apda_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_apda_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Apda_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 12 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ea71f99dced71b36e9b20a40ec31d554f43f5f73 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_apda_bss.Api_2_Erh_Apda_Bss_1 +uicc.test.toolkit.api_2_erh_apda_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/javacard/api_2_erh_apda_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/javacard/api_2_erh_apda_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..c7077a0287fc9a7aebf2b309d3c0876ac1b3cce7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_apda_bss/javacard/api_2_erh_apda_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/Api_2_Erh_Aptlb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/Api_2_Erh_Aptlb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..600fcd46a24a57b1e50e5aab26deab7ffd8cb0b2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/Api_2_Erh_Aptlb_Bss_1.java @@ -0,0 +1,506 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlb_bss; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlb_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlb_Bss_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[256] ; + private byte buffer5[] = new byte[5] ; + private byte buffer256[] = new byte[256] ; + private byte buffer[] = new byte[32] ; + private byte copyBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlb_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlb_Bss_1 thisApplet = new Api_2_Erh_Aptlb_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short length = 0 ; + short offset = 0 ; + short valueLength = 0 ; + short valueOffset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null value + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, null, valueOffset, valueLength) ; + } + catch (NullPointerException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : valueOffset >= value.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)5 ; + valueLength = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : valueOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)-1 ; + valueLength = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : valueLength > value.Length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)6 ; + + try { + EnvRespHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : valueOffset + valueLength > value.Length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)3 ; + valueLength = (short)3 ; + + try { + EnvRespHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : valueLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)-1 ; + + try { + EnvRespHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : handler overflow + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)(EnvRespHdlr.getCapacity() - 1) ; + + try { + EnvRespHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : bad input parameter + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)256 ; + + try { + EnvRespHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : the current TLV is not modified + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + EnvRespHdlr.clear(); + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + for (short i=0; i<(short)8; i++) + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + tag = (byte)0x04 ; + valueOffset = (short)0 ; + valueLength = (short)8 ; + EnvRespHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()== (short)3) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + testCaseNb = (byte) 10 ; + bRes = false ; + + tag = (byte)4 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + compareBuffer[(short)(i+2)] = (byte)((byte)0xFF-i) ; // 04 08 FF FE FD FC FB FA F9 F8 + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)8 ; + + try { + + //erase the copy buffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append buffer + valueOffset = (short)0 ; + valueLength = (short)8 ; + EnvRespHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Copy the handler + offset = (short) 0 ; + length = (short) EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + testCaseNb = (byte) 11 ; + bRes = false ; + + tag = (byte)0x85 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + } + compareBuffer[10] = tag ; + compareBuffer[11] = (byte)0x06 ; + for (short i=0; i<(short)6; i++) { + compareBuffer[(short)(12+i)] = (byte)(i+2) ; // 04 08 FF FE FD FC FB FA F9 F8 85 06 02 03 04 05 06 07 + } + + + try { + + //erase the copy buffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Append buffer + valueOffset = (short)2 ; + valueLength = (short)6 ; + EnvRespHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Copy the handler + offset = (short)0 ; + length = (short)EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + tag = (byte) 0x01 ; + // Initialise buffers + for (short i=0; i<8; i++) { + buffer[i] = (byte) ((i+1)*0x11) ; // 11 22 33 44 55 66 77 88 + } + + compareBuffer[18] = tag ; + compareBuffer[19] = (byte) 0x04 ; + compareBuffer[20] = (byte) 0x33 ; + compareBuffer[21] = (byte) 0x44 ; + compareBuffer[22] = (byte) 0x55 ; + compareBuffer[23] = (byte) 0x66 ; + + try { + + //erase the copy buffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Append buffer + valueOffset = (short)2 ; + valueLength = (short)4 ; + EnvRespHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Copy the handler + offset = (short)0 ; + length = (short)EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successfull call + testCaseNb = (byte) 13 ; + bRes = false ; + + tag = (byte)04 ; + + // Initialise buffers + for (short i=0; i<(short)81; i++) { + buffer256[i] = (byte)i ; + compareBuffer[(short)(i+3)] = (byte)i ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0x80 ; + + try { + + //erase the copy buffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append buffer + valueOffset = (short)0 ; + valueLength = (short)0x80 ; + EnvRespHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + + // Copy the handler + offset = (short) 0 ; + length = (short)EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 14 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append buffer + try { + valueOffset = (short)0 ; + valueLength = (short)0x80 ; + EnvRespHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/Test_Api_2_Erh_Aptlb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/Test_Api_2_Erh_Aptlb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..c0c084a08817d8fd024ff9e6d27fe517e25803ae --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/Test_Api_2_Erh_Aptlb_Bss.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlb_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlb_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlb_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlb_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 14 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4d7f0546dd12636a515034ce3ab10726d22978e8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlb_bss.Api_2_Erh_Aptlb_Bss_1 +uicc.test.toolkit.api_2_erh_aptlb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/javacard/api_2_erh_aptlb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/javacard/api_2_erh_aptlb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..2050d2aa40f6ffcd4c7365911212e5a62e23c8eb Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss/javacard/api_2_erh_aptlb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/Api_2_Erh_Aptlb_Bss_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/Api_2_Erh_Aptlb_Bss_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..c277e3ac991f1a1b9d5e415c0454231ceb6e3819 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/Api_2_Erh_Aptlb_Bss_Bss_1.java @@ -0,0 +1,673 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlb_Bss_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlb_bss_bss; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlb_bss_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlb_Bss_Bss_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[256] ; + private byte value1[] = new byte[5] ; + private byte value2[] = new byte[5] ; + private byte buffer256[] = new byte[256] ; + private byte buffer[] = new byte[32] ; + private byte copyBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlb_Bss_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlb_Bss_Bss_1 thisApplet = new Api_2_Erh_Aptlb_Bss_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short value1Offset = 0 ; + short value1Length = 0 ; + short value2Length = 0 ; + short value2Offset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null value1 + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + tag = (byte)1 ; + + value1Offset = (short)0 ; + value1Length = (short)1 ; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, null, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 1 : Null value1 + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + tag = (byte)1 ; + + value1Offset = (short)0 ; + value1Length = (short)1 ; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,null,value2Offset, value2Length); + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : value1Offset >= value1.length + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + tag = (byte)1 ; + value1Offset = (short)5 ; + value1Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : value1Offset < 0 + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + tag = (byte)1 ; + value1Offset = (short)-1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : value1Length > value1.Length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + tag = (byte)1 ; + value1Offset = (short)0 ; + value1Length = (short)6 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : value1Offset + value1Length > value1.length + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + tag = (byte)1 ; + value1Offset = (short)3 ; + value1Length = (short)3 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : value1Length < 0 + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + tag = (byte)1 ; + value1Offset = (short)0 ; + value1Length = (short)-1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : value2Offset >= value2.length + testCaseNb = (byte) 8 ; + bRes = false ; + value1Offset = (short)0 ; + value1Length = (short)1 ; + + try { + tag = (byte)1 ; + value2Offset = (short)5 ; + value2Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : value2Offset < 0 + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)-1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : value2Length > value2.Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)6 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : value2Offset + value2Length > value2.length + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)3 ; + value2Length = (short)3 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : value2Length < 0 + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)-1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, value1Offset,value1Length,value2,value2Offset, value2Length); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 13 : handler overflow + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + tag = (byte)1 ; + EnvRespHdlr.appendArray(buffer256,(short)0,(short)(EnvRespHdlr.getCapacity() - 1)); + + try { + EnvRespHdlr.appendTLV(tag, buffer256,(short)0,(short)1,buffer256,(short)0,(short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : bad input parameter + testCaseNb = (byte) 14 ; + bRes = false ; + value1 = new byte[256]; + value2 = new byte[256]; + + try { + tag = (byte)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1,(short)0,(short)0x0100,value2,(short)0,(short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : bad input parameter + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + tag = (byte)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1,(short)0,(short)1,value2,(short)0,(short)0x100) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 9 : the current TLV is not modified + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + for (short i=0; i<(short)8; i++) + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + + for (short i=8; i<(short)0x11; i++) + buffer[i] = (byte) ((byte)0xFF-i) ; + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + tag = (byte)0x04 ; + value1Offset = (short)0 ; + value1Length = (short)8 ; + value2Offset = (short)8 ; + value2Length = (short)8 ; + EnvRespHdlr.appendTLV(tag, buffer,value1Offset,value1Length,buffer,value2Offset, value2Length) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==3) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Successfull call + testCaseNb = (byte) 17 ; + bRes = false ; + + tag = (byte)4 ; + + // Initialise buffers + Util.arrayCopyNonAtomic(buffer,(short)0,compareBuffer,(short)2,(short)0x10); + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x10 ; + + try { + + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append buffer + value1Offset = (short)0 ; + value1Length = (short)8 ; + + value2Offset = (short)8 ; + value2Length = (short)8 ; + EnvRespHdlr.appendTLV(tag, buffer,value1Offset,value1Length,buffer,value2Offset, value2Length) ; + + // Copy the handler + EnvRespHdlr.copy(copyBuffer,(short)0,(short) EnvRespHdlr.getLength()) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer,(short)0, compareBuffer, (short)0,(short)0x10)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successfull call + testCaseNb = (byte) 18 ; + bRes = false ; + + tag = (byte)0x85 ; + + // Initialise buffers + for (short i=0; i<(short)0x10; i++) + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + + compareBuffer[0x12] = tag ; + compareBuffer[0x13] = (byte)0x0C ; + Util.arrayCopyNonAtomic(buffer,(short)0x02,compareBuffer,(short)0x14,(short)0x06); + Util.arrayCopyNonAtomic(buffer,(short)0x0A,compareBuffer,(short)0x1A,(short)0x06); + + try { + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Append buffer + value1 = new byte[8]; + Util.arrayCopyNonAtomic(buffer,(short)0,value1,(short)0,(short)value1.length); + value1Offset = (short)2 ; + value1Length = (short)6 ; + value2 = new byte[8]; + Util.arrayCopyNonAtomic(buffer,(short)8,value2,(short)0,(short)value2.length); + value2Offset = (short)2 ; + value2Length = (short)6 ; + EnvRespHdlr.appendTLV(tag, value1,value1Offset,value1Length,value2,value2Offset,value2Length) ; + + // Copy the handler + EnvRespHdlr.copy(copyBuffer, (short)0,(short) EnvRespHdlr.getLength()) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer,(short)0, compareBuffer,(short)0, EnvRespHdlr.getLength())==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 19 : Successfull call + testCaseNb = (byte) 19 ; + bRes = false ; + + tag = (byte) 0x01 ; + // Initialise buffers + for (short i=1; i<0x11; i++) + buffer[i] = (byte) (i*0x11) ; // 11 22 33 44 55 66 77 88 + + compareBuffer[0x20] = tag ; + compareBuffer[0x21] = (byte) 0x08 ; + Util.arrayCopyNonAtomic(buffer,(short)0x02,compareBuffer,(short)0x22,(short)0x04); + Util.arrayCopyNonAtomic(buffer,(short)0x0B,compareBuffer,(short)0x26,(short)0x04); + + try { + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Initialise value1 and value2 + Util.arrayCopyNonAtomic(buffer,(short)0,value1,(short)0,(short)value1.length); + Util.arrayCopyNonAtomic(buffer,(short)9,value2,(short)0,(short)value1.length); + value2[7] = (byte)0; + + value1Offset = (short)2 ; + value1Length = (short)4 ; + + value2Offset = (short)2 ; + value2Length = (short)4 ; + EnvRespHdlr.appendTLV(tag, value1,value1Offset,value1Length,value2,value2Offset, value2Length) ; + + // Copy the handler + EnvRespHdlr.copy(copyBuffer,(short) 0, EnvRespHdlr.getLength()) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer,(short)0, compareBuffer, (short)0, EnvRespHdlr.getLength())==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 20 : Successfull call + testCaseNb = (byte) 20 ; + bRes = false ; + + tag = (byte)04 ; + + // Initialise buffers + for (short i=0; i<(short)0x00FD; i++) { + buffer256[i] = (byte)(i) ; + compareBuffer[(short)(i+3)] = (byte)(i) ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xFD ; + + try { + + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Clear the handler + EnvRespHdlr.clear() ; + + // Initialise value1 and value2 + value1 = new byte[128]; + Util.arrayCopyNonAtomic(buffer256,(short)0,value1,(short)0,(short)value1.length); + value1Offset = (short)0; + value1Length = (short)0x80; + + value2 = new byte[125]; + Util.arrayCopyNonAtomic(buffer256,(short)0x80,value2,(short)0,(short)value2.length); + value2Offset = (short)0; + value2Length = (short)0x7D ; + EnvRespHdlr.appendTLV(tag, value1,value1Offset,value1Length,value2,value2Offset, value2Length) ; + + // Copy the handler + EnvRespHdlr.copy(copyBuffer,(short)0, EnvRespHdlr.getLength()) ; + + byte[] toto = new byte[256]; + Util.arrayCopyNonAtomic(compareBuffer,(short)0,toto,(short)0,(short)EnvRespHdlr.getLength()); + + // Compare buffer + if(Util.arrayCompare(copyBuffer, (short)0, compareBuffer,(short)0, EnvRespHdlr.getLength())==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 21 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append buffer + try { + value1Offset = (short)0; + value1Length = (short)0x01; + value2Offset = (short)0; + value2Length = (short)0x01; + EnvRespHdlr.appendTLV(tag, buffer256,value1Offset,value1Length,buffer256,value2Offset, value2Length) ; + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/Test_Api_2_Erh_Aptlb_Bss_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/Test_Api_2_Erh_Aptlb_Bss_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..f1e9b4f3edf603a6bc2b213af08e7b505b03f94c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/Test_Api_2_Erh_Aptlb_Bss_Bss.java @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlb_Bss_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlb_bss_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlb_bss_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlb_Bss_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlb_bss_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlb_Bss_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 15 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "15CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..0f947ad219c8b4091a2565ad8e5a75e9a020e448 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlb_bss_bss.Api_2_Erh_Aptlb_Bss_Bss_1 +uicc.test.toolkit.api_2_erh_aptlb_bss_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/javacard/api_2_erh_aptlb_bss_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/javacard/api_2_erh_aptlb_bss_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..28911329bbc720ec206bf637be856e63959209cc Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlb_bss_bss/javacard/api_2_erh_aptlb_bss_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/Api_2_Erh_Aptlbb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/Api_2_Erh_Aptlbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f3bdd8a4fce76e5d70f718e3c8f05c46a19810fe --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/Api_2_Erh_Aptlbb_1.java @@ -0,0 +1,244 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlbb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbb; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbb + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlbb_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[10] ; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlbb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlbb_1 thisApplet = new Api_2_Erh_Aptlbb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + byte value = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + buffer[1] = (byte) 0x81; + buffer[2] = (byte) 250; + length = (short)(EnvRespHdlr.getCapacity() - 1) ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // appendTLV + try { + EnvRespHdlr.appendTLV(tag, value) ; + EnvRespHdlr.appendTLV(tag, value) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + EnvRespHdlr.appendTLV(tag, value) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==(short)3) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value = (byte)0x00 ; + EnvRespHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 1; + compareBuffer[2] = value ; + + // Copy the handler + offset = (short)0 ; + length = (short)3 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Append TLV + tag = (byte)0x01 ; + value = (byte)0xFE ; + EnvRespHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[3] = tag ; + compareBuffer[4] = (byte) 1; + compareBuffer[5] = value ; + + // Copy the handler + offset = (short)0 ; + length = (short)6 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append TLV + try { + tag = (byte)0x01 ; + value = (byte)0xFE ; + EnvRespHdlr.appendTLV(tag, value) ; + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/Test_Api_2_Erh_Aptlbb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/Test_Api_2_Erh_Aptlbb.java new file mode 100644 index 0000000000000000000000000000000000000000..56aa79d010c00b1d712ee0e070d27753517b6666 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/Test_Api_2_Erh_Aptlbb.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlbb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbb + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlbb extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlbb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlbb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 5 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..323b19fbdc2007acf4206e30e3d56003a6fc34a7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlbb.Api_2_Erh_Aptlbb_1 +uicc.test.toolkit.api_2_erh_aptlbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/javacard/api_2_erh_aptlbb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/javacard/api_2_erh_aptlbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..5a778411794c4115e3675b827264fd393b738084 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb/javacard/api_2_erh_aptlbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/Api_2_Erh_Aptlbb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/Api_2_Erh_Aptlbb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..afd3f45f68103a9c2dd1d42492bcb9a78e6ce52e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/Api_2_Erh_Aptlbb_Bss_1.java @@ -0,0 +1,511 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlbb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbb_bss; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbb_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlbb_Bss_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[256] ; + private byte buffer5[] = new byte[5] ; + private byte buffer256[] = new byte[256] ; + private byte buffer[] = new byte[32] ; + private byte copyBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlbb_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlbb_Bss_1 thisApplet = new Api_2_Erh_Aptlbb_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short length = 0 ; + short offset = 0 ; + byte value1 = 0 ; + short value2Length = 0 ; + short value2Offset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null value + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, null, value2Offset, value2Length) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : value2Offset >= value2.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)5 ; + value2Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : value2Offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)-1 ; + value2Length = (short)1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : value2Length > value2.Length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)6 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : value2Offset + value2Length > value2.Length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)3 ; + value2Length = (short)3 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : valueLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)-1 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : handler overflow + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)(EnvRespHdlr.getCapacity() - 3) ; + byte[] large_buffer = new byte[value2Length]; + Util.arrayFillNonAtomic(large_buffer,(short)0,(short)large_buffer.length,(byte)0); + EnvRespHdlr.appendArray(large_buffer,(short)0,value2Length); + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer256, value2Offset, (short)1); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : bad input parameter + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)255 ; + + try { + EnvRespHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : the current TLV is not modified + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + for (short i=0; i<(short)8; i++) + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + tag = (byte)0x04 ; + value1 = (byte)0x05 ; + value2Offset = (short)0 ; + value2Length = (short)8 ; + EnvRespHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==3) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + testCaseNb = (byte) 10 ; + bRes = false ; + + tag = (byte)4 ; + value1 = (byte)0x05 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + compareBuffer[(short)(i+3)] = (byte)((byte)0xFF-i) ; // 04 08 FF FE FD FC FB FA F9 F8 + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)9 ; + compareBuffer[2] = value1 ; + + + try { + + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append buffer + value2Offset = (short)0 ; + value2Length = (short)8 ; + EnvRespHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Copy the handler + offset = (short) 0 ; + length = (short) EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + testCaseNb = (byte) 11 ; + bRes = false ; + + tag = (byte)0x85 ; + value1 = (byte)0x55 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + + compareBuffer[11] = tag ; + compareBuffer[12] = (byte)0x07 ; + compareBuffer[13] = value1 ; + + for (short i=0; i<(short)6; i++) + compareBuffer[(short)(14+i)] = (byte)(i+2) ; // 04 08 FF FE FD FC FB FA F9 F8 85 06 02 03 04 05 06 07 + + try { + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Append buffer + value2Offset = (short)2 ; + value2Length = (short)6 ; + EnvRespHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + tag = (byte) 0x01 ; + value1 = (byte) 0x44 ; + // Initialise buffers + for (short i=0; i<8; i++) + buffer[i] = (byte) ((i+1)*0x11) ; // 11 22 33 44 55 66 77 88 + + compareBuffer[20] = tag ; + compareBuffer[21] = (byte) 0x05 ; + compareBuffer[22] = value1 ; + compareBuffer[23] = (byte) 0x33 ; + compareBuffer[24] = (byte) 0x44 ; + compareBuffer[25] = (byte) 0x55 ; + compareBuffer[26] = (byte) 0x66 ; + + try { + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Append buffer + value2Offset = (short)2 ; + value2Length = (short)4 ; + EnvRespHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successfull call + testCaseNb = (byte) 13 ; + bRes = false ; + + tag = (byte)04 ; + value1 = (byte) 0x00 ; + + // Initialise buffers + for (short i=0; i<(short)80; i++) { + buffer256[i] = (byte)(i+1) ; + compareBuffer[(short)(i+4)] = (byte)(i+1) ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0x80 ; + compareBuffer[3] = value1 ; + + try { + + //erase the copybuffer + Util.arrayFillNonAtomic(copyBuffer,(short)0,(short)copyBuffer.length,(byte)0x00); + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append buffer + value2Offset = (short)0 ; + value2Length = (short)0x7F ; + EnvRespHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + + // Copy the handler + offset = (short) 0 ; + length = (short)EnvRespHdlr.getLength() ; + EnvRespHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + if(Util.arrayCompare(copyBuffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 14 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append buffer + try { + value2Offset = (short)0 ; + value2Length = (short)0x7F ; + EnvRespHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/Test_Api_2_Erh_Aptlbb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/Test_Api_2_Erh_Aptlbb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..d9a7f109b128b28f9415b86ae69df993adf77bcc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/Test_Api_2_Erh_Aptlbb_Bss.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlbb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbb_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbb_bss + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlbb_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlbb_Bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlbb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 14 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d2788cc4ef0d783578d67de0cf0cafbd1a2d9322 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlbb_bss.Api_2_Erh_Aptlbb_Bss_1 +uicc.test.toolkit.api_2_erh_aptlbb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/javacard/api_2_erh_aptlbb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/javacard/api_2_erh_aptlbb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..e148feaa5a1cc0d2b8b69f3286483b89bf7bd8fa Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbb_bss/javacard/api_2_erh_aptlbb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/Api_2_Erh_Aptlbbb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/Api_2_Erh_Aptlbbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..2df645d3bf1df6d31df25cdde576baf8a5dc16b1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/Api_2_Erh_Aptlbbb_1.java @@ -0,0 +1,247 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlbbb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbbb; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbbb + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlbbb_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[10] ; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlbbb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlbbb_1 thisApplet = new Api_2_Erh_Aptlbbb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + byte value1 = 0 ; + byte value2 = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + length = (short)(EnvRespHdlr.getCapacity() - 1) ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // appendTLV + try { + EnvRespHdlr.appendTLV(tag, value1, value2) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==3) + bRes =true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value1 = (byte)0x00 ; + value2 = (byte)0x01 ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 2; + compareBuffer[2] = value1 ; + compareBuffer[3] = value2 ; + + // Copy the handler + offset = (short)0 ; + length = (short)4 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Append TLV + tag = (byte)0x01 ; + value1 = (byte)0xFE ; + value2 = (byte)0xFD ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[4] = tag ; + compareBuffer[5] = (byte) 2; + compareBuffer[6] = value1 ; + compareBuffer[7] = value2 ; + + // Copy the handler + offset = (short)0 ; + length = (short)8 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append TLV + try { + tag = (byte)0x01 ; + value1 = (byte)0xFE ; + value2 = (byte)0xFD ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/Test_Api_2_Erh_Aptlbbb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/Test_Api_2_Erh_Aptlbbb.java new file mode 100644 index 0000000000000000000000000000000000000000..1dd4c93759ad82a351d255894ff8790a7f44a732 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/Test_Api_2_Erh_Aptlbbb.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlbbb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbbb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbbb + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlbbb extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlbbb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlbbb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 5 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..8420a08654027e6e0107419b05c6fdb58245e228 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlbbb.Api_2_Erh_Aptlbbb_1 +uicc.test.toolkit.api_2_erh_aptlbbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/javacard/api_2_erh_aptlbbb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/javacard/api_2_erh_aptlbbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..0fe428bd00a33f60f3bd792be29afda97213ac1a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbb/javacard/api_2_erh_aptlbbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/Api_2_Erh_Aptlbbs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/Api_2_Erh_Aptlbbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..813e28ad60541c2e1a3ecdf8bdfd02e51ac74482 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/Api_2_Erh_Aptlbbs_1.java @@ -0,0 +1,243 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlbbs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbbs; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbbs + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlbbs_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[10] ; + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlbbs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlbbs_1 thisApplet = new Api_2_Erh_Aptlbbs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + byte value1 = 0 ; + short value2 = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + length = (short)(EnvRespHdlr.getCapacity() - 1) ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // appendTLV + try { + EnvRespHdlr.appendTLV(tag, value1, value2) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x81,(byte)0x11,(short)0x2233); + + //built the second tlv + EnvRespHdlr.appendTLV((byte)0x82,(byte)0x99,(byte)0x77); + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==3) + bRes =true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value1 = (byte)0x00 ; + value2 = (short)0x0102 ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 3; + compareBuffer[2] = value1 ; + compareBuffer[3] = (byte)(value2 >> 8); + compareBuffer[4] = (byte)value2; + + // Copy the handler + offset = (short)0 ; + length = (short)5 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Append TLV + tag = (byte)0x01 ; + value1 = (byte)0xFE ; + value2 = (short)0xFDFC ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[5] = tag ; + compareBuffer[6] = (byte) 3; + compareBuffer[7] = value1 ; + compareBuffer[8] = (byte)(value2 >> 8); + compareBuffer[9] = (byte)value2; + + // Copy the handler + offset = (short)0 ; + length = (short)0x0A ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append TLV + try { + tag = (byte)0x01 ; + value1 = (byte)0xFE ; + value2 = (byte)0xFDFC ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/Test_Api_2_Erh_Aptlbbs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/Test_Api_2_Erh_Aptlbbs.java new file mode 100644 index 0000000000000000000000000000000000000000..0db5163ef1b30c49ec2a87733fe3e19afaf11a0c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/Test_Api_2_Erh_Aptlbbs.java @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Aptlbbs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbbs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbbs + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlbbs extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlbbs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlbbs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 5 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b26536288899ce449f2d56e75081efcb427cdec6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlbbs.Api_2_Erh_Aptlbbs_1 +uicc.test.toolkit.api_2_erh_aptlbbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/javacard/api_2_erh_aptlbbs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/javacard/api_2_erh_aptlbbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..08d23dac7d7ed83ff1a5a9d8cd6148db696d949a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbbs/javacard/api_2_erh_aptlbbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/Api_2_Erh_Aptlbs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/Api_2_Erh_Aptlbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6d8be677bc66398d37618b4bbc9fcb90efc47d02 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/Api_2_Erh_Aptlbs_1.java @@ -0,0 +1,242 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlbs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbs; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbs + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlbs_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[10] ; + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlbs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlbs_1 thisApplet = new Api_2_Erh_Aptlbs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short value = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + buffer[1] = (byte) 0x81; + buffer[2] = (byte) 250; + length = (short)(EnvRespHdlr.getCapacity() - 1); + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // appendTLV + try { + EnvRespHdlr.appendTLV(tag, value) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + EnvRespHdlr.appendTLV((byte)0x82,(short) 0x9977); + + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + EnvRespHdlr.appendTLV(tag, value) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==(short)3) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value = (short)0x0001 ; + EnvRespHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 0x02; + compareBuffer[2] = (byte)(value >> 8); + compareBuffer[3] = (byte)value; + + // Copy the handler + offset = (short)0 ; + length = (short)4 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Append TLV + tag = (byte)0x01 ; + value = (short)0xFEFF ; + EnvRespHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[4] = tag ; + compareBuffer[5] = (byte) 2; + compareBuffer[6] = (byte)(value >> 8); + compareBuffer[7] = (byte)value; + + // Copy the handler + offset = (short)0 ; + length = (short)8 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append TLV + try { + tag = (byte)0x01 ; + value = (byte)0xFEFF ; + EnvRespHdlr.appendTLV(tag, value) ; + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/Test_Api_2_Erh_Aptlbs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/Test_Api_2_Erh_Aptlbs.java new file mode 100644 index 0000000000000000000000000000000000000000..d19baae5bc220e0c25214eb7c95d80858f97b5bf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/Test_Api_2_Erh_Aptlbs.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlbs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbs + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlbs extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlbs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlbs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 5 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..535146f4ebf8ccb750d49039b9c63f34f76e7bc5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlbs.Api_2_Erh_Aptlbs_1 +uicc.test.toolkit.api_2_erh_aptlbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/javacard/api_2_erh_aptlbs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/javacard/api_2_erh_aptlbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..0753e3be0c974c5f4ae710571adaa408dedc361a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbs/javacard/api_2_erh_aptlbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/Api_2_Erh_Aptlbss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/Api_2_Erh_Aptlbss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..9299f66ff57b79a6d53b353fb33fb33a222d4375 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/Api_2_Erh_Aptlbss_1.java @@ -0,0 +1,237 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Aptlbss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbss + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Aptlbss_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[12] ; + /** + * Constructor of the applet + */ + public Api_2_Erh_Aptlbss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Aptlbss_1 thisApplet = new Api_2_Erh_Aptlbss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short value1 = 0 ; + short value2 = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + length = (short)(EnvRespHdlr.getCapacity() - 1) ; + EnvRespHdlr.appendArray(buffer, offset, length) ; + + // appendTLV + try { + EnvRespHdlr.appendTLV(tag, value1, value2) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // clear the handler + EnvRespHdlr.clear(); + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x81,(byte)0x11,(short)0x2233); + + //built the second tlv + EnvRespHdlr.appendTLV((byte)0x82,(byte)0x99,(byte)0x77); + + // Select tag 02h + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Verify current TLV + if(EnvRespHdlr.getValueLength()==3) + bRes =true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + //erase the begin of the array + for(short i=0;i<10;i++) + buffer[i]=(byte)0x00; + + // Clear the handler + EnvRespHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value1 = (short)0x0001 ; + value2 = (short)0x0203 ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 4; + compareBuffer[2] = (byte)(value1 >> 8); + compareBuffer[3] = (byte) value1; + compareBuffer[4] = (byte)(value2 >> 8); + compareBuffer[5] = (byte)value2; + + // Copy the handler + offset = (short)0 ; + length = (short)6 ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Append TLV + tag = (byte)0x01 ; + value1 = (short)0xFEFD ; + value2 = (short)0xFCFB ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[6] = tag ; + compareBuffer[7] = (byte) 4; + compareBuffer[8] = (byte)(value1 >> 8); + compareBuffer[9] = (byte) value1 ; + compareBuffer[10] = (byte)(value2 >> 8); + compareBuffer[11] = (byte)value2; + + // Copy the handler + offset = (short)0 ; + length = (short)0x0C ; + EnvRespHdlr.copy(buffer, offset, length) ; + + // Compare the handler + if(Util.arrayCompare(buffer, offset, compareBuffer, offset, length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + // Append TLV + try { + tag = (byte)0x01 ; + value1 = (byte)0xFEFD ; + value2 = (byte)0xFCFB ; + EnvRespHdlr.appendTLV(tag, value1, value2) ; + + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/Test_Api_2_Erh_Aptlbss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/Test_Api_2_Erh_Aptlbss.java new file mode 100644 index 0000000000000000000000000000000000000000..217d9f6fea962f814a63fb9e61a81e0bcad8ab1e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/Test_Api_2_Erh_Aptlbss.java @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Aptlbss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_aptlbss; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.api_2_erh_aptlbss + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Aptlbss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_aptlbss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Aptlbss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() + { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 5 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9d50184e7a6381b747dfc92368d36a6fb2c43ebb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_aptlbss.Api_2_Erh_Aptlbss_1 +uicc.test.toolkit.api_2_erh_aptlbss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/javacard/api_2_erh_aptlbss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/javacard/api_2_erh_aptlbss.cap new file mode 100644 index 0000000000000000000000000000000000000000..663b35551aafac465382a83619005b3c51c7ba25 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_aptlbss/javacard/api_2_erh_aptlbss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/Api_2_Erh_Cler_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/Api_2_Erh_Cler_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7ad85dfa961c80d67ded1ac4092d2ff853c87295 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/Api_2_Erh_Cler_1.java @@ -0,0 +1,161 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Cler_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_cler; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_cler + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Cler_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte compareBuffer[] = new byte[256] ; + private byte buffer5[] = new byte[5] ; + private byte buffer256[] = new byte[256] ; + private byte buffer[] = new byte[32] ; + private byte copyBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Cler_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Cler_1 thisApplet = new Api_2_Erh_Cler_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Successful call + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + byte[] buffer=new byte[4]; + + //built the first tlv + buffer[0]=(byte)0x11; + buffer[1]=(byte)0x22; + buffer[3]=(byte)0x33; + EnvRespHdlr.appendTLV((byte)0x81,buffer,(short) 0x00, (short) 3); + + //built the second tlv + buffer[0]=(byte)0x99; + buffer[1]=(byte)0x77; + EnvRespHdlr.appendTLV((byte)0x82,buffer,(short) 0x00, (short) 2); + + // Select command Details TLV + EnvRespHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Verify the length of the handler + bRes = (EnvRespHdlr.getLength() == 9) ; + + } + catch (Exception e) { + bRes = false ; + } + + try { + + //clear the handler + EnvRespHdlr.clear() ; + + // Verify the length of the handler + bRes &= (EnvRespHdlr.getLength() == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : A successful call resets the current TLV selected + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + EnvRespHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.clear(); + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/Test_Api_2_Erh_Cler.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/Test_Api_2_Erh_Cler.java new file mode 100644 index 0000000000000000000000000000000000000000..827e55af4726ce1d76fe9914b2f2bd6b1b1de804 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/Test_Api_2_Erh_Cler.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Tes_Api_2_Erh_Cler.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_cler; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_cler + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Cler extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_cler"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Cler() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 3 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "03CCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..93c48a845e788b78904912f0043ef37e56eaf4b7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_cler.Api_2_Erh_Cler_1 +uicc.test.toolkit.api_2_erh_cler +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/javacard/api_2_erh_cler.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/javacard/api_2_erh_cler.cap new file mode 100644 index 0000000000000000000000000000000000000000..d38f863c6cb5841193cd8a46c257a981d885c160 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cler/javacard/api_2_erh_cler.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/Api_2_Erh_Copy_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/Api_2_Erh_Copy_1.java new file mode 100644 index 0000000000000000000000000000000000000000..10c0cd7fd63be635e24d2e590ccf7a8a6bb0bef8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/Api_2_Erh_Copy_1.java @@ -0,0 +1,385 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Copy_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_copy; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_copy + * + * @version 0.0.1 - 5 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Copy_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Copy_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Copy_1 thisApplet = new Api_2_Erh_Copy_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event){ + + // Result of tests + boolean bRes ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) { + + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : try to use copy value method with the destination buffer null + testCaseNb = (byte) 1 ; + bRes = false ; + + // Null as dstBuffer + try { + // Build a 7Fh byte command + EnvRespHdlr.appendTLV((byte)0x33,data,(short) 0x00, (short) 0x07); + EnvRespHdlr.copy(null, (short)0, (short)1) ; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : dstOffset >= dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[5] ; + EnvRespHdlr.copy(dstBuffer, (short)5, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[5] ; + EnvRespHdlr.copy(dstBuffer, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[5] ; + EnvRespHdlr.copy(dstBuffer, (short)0, (short)6) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[5] ; + EnvRespHdlr.copy(dstBuffer, (short)3, (short)3) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[5] ; + + EnvRespHdlr.copy(dstBuffer, (short)0, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : dstLength > length of the simple TLV list + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[10] ; + EnvRespHdlr.copy(dstBuffer, (short)0, (short)10) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : Successful call, whole buffer + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + byte[] dstBuffer = new byte[9] ; + if(EnvRespHdlr.copy(dstBuffer, (short)0, (short)9)==9) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Compare the buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + byte[] compareBuffer = new byte[9] ; + + try { + // Initialise buffers + Util.arrayCopyNonAtomic(data,(short)0,compareBuffer,(short)2,(short)7); + compareBuffer[0]=0x33; + compareBuffer[1]=0x07; + + // Compare buffers + byte[] dstBuffer = new byte[9] ; + + if( (EnvRespHdlr.copy(dstBuffer, (short)0, (short)9)==9) + && (Util.arrayCompare(compareBuffer, (short)0,dstBuffer, (short)0, (short)9)==0)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 10 : Successful call, part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + // Compare buffers + byte[] dstBuffer = new byte[143] ; + + EnvRespHdlr.appendTLV((byte)0x34,data,(short) 0x00, (short)0x0080); + try { + if(EnvRespHdlr.copy(dstBuffer, (short)3, (short)0x8C)==(short)0x8F) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 11 : Compare the buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + compareBuffer = new byte[143] ; + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0); + compareBuffer[3]=0x33; + compareBuffer[4]=0x07; + Util.arrayCopyNonAtomic(data,(short)0,compareBuffer,(short)5,(short)7); + + compareBuffer[12]=0x34; + compareBuffer[13]=(byte)0x81; + compareBuffer[14]=(byte)0x80; + Util.arrayCopyNonAtomic(data,(short)0,compareBuffer,(short)15,(short)0x80); + + try { + if( (EnvRespHdlr.copy(dstBuffer, (short)3, (short)0x8C)==(short)0x8F) + && (Util.arrayCompare(compareBuffer, (short)0,dstBuffer, (short)0, (short)compareBuffer.length)==0)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + return; + + case (byte) 11 : + + // -------------------------------------------- + // Test Case 12 : Successful call, part of a buffer + testCaseNb = (byte) 12 ; + bRes = false ; + + dstBuffer = new byte[15] ; + + EnvRespHdlr.appendTLV((byte)0x33,data,(short) 0x00, (short) 13); + + try { + if(EnvRespHdlr.copy(dstBuffer, (short)3, (short)6)==9) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare the buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + // Compare buffers + compareBuffer = new byte[15] ; + dstBuffer = new byte[15] ; + + compareBuffer[3]=0x33; + compareBuffer[4]=0x0D; + Util.arrayCopy(data, (short)0,compareBuffer, (short)5, (short)4); + + try { + if((EnvRespHdlr.copy(dstBuffer, (short)3, (short)6)==9)&& + (Util.arrayCompare(compareBuffer, (short)0,dstBuffer, (short)0, (short)15)==0)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 14 : successful call with the length=0 and the offset = length of the destination buffer + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + if(EnvRespHdlr.copy(dstBuffer, (short)dstBuffer.length, (short)0)==15) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + return; + + + case (byte) 14 : + // -------------------------------------------- + // Test Case 15 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 15 ; + bRes = false ; + dstBuffer = new byte[10] ; + + try { + EnvRespHdlr.post(true); + try { + EnvRespHdlr.copy(dstBuffer, (short)0, (short)0); + bRes=false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + return; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/Test_Api_2_Erh_Copy.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/Test_Api_2_Erh_Copy.java new file mode 100644 index 0000000000000000000000000000000000000000..a018d8c5a807311e3c8062b88982a412783f0707 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/Test_Api_2_Erh_Copy.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Copy.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_copy; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_copy + * + * @version 0.0.1 - 5 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Copy extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_copy"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Copy() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 11 + test.unrecognizedEnvelope(); + + // Test case 11 to 14 + test.unrecognizedEnvelope(); + + // Test case 15 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0FCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..96b3323b009fd6f3e85f84c5afeb52d396fae72b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_copy.Api_2_Erh_Copy_1 +uicc.test.toolkit.api_2_erh_copy +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/javacard/api_2_erh_copy.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/javacard/api_2_erh_copy.cap new file mode 100644 index 0000000000000000000000000000000000000000..9e614d5c43f640e2b0cbf5e2a0152b1ee1c0666c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_copy/javacard/api_2_erh_copy.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/Api_2_Erh_Cprv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/Api_2_Erh_Cprv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..99585aa4accc461932defac18948357e01d66aa0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/Api_2_Erh_Cprv_1.java @@ -0,0 +1,491 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Cprv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_cprv; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_cprv + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Cprv_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] ref_data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Cprv_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Cprv_1 thisApplet = new Api_2_Erh_Cprv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Null as compareBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + byte[] TLVBuffer = new byte[16]; + + //initialize the buffer + for(short i=0;i<16;i++) + TLVBuffer[i]=(byte)i; + + //built the first TLV + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 16); + + // Select the TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + try { + EnvRespHdlr.compareValue((short)0, null, (short)0, (short)1) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : compareOffset >= compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + byte[] compareBuffer = new byte[5]; + + try { + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)5, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareLength > compareBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)6) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + compareLength > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)3, (short)3) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compareLength < 0 + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= TLV Length + testCaseNb = (byte) 7 ; + bRes = false ; + + compareBuffer=new byte[15]; + + try { + //initialize the buffer + for(short i=0;i<15;i++) + compareBuffer[i]=(byte)i; + + EnvRespHdlr.clear(); + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,compareBuffer,(short) 0x00, (short) 6); + + // Select Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + try { + EnvRespHdlr.compareValue((short)6, compareBuffer, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)-1, compareBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : compareLength > TLV length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)7) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + compareLength > Text String length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + try { + EnvRespHdlr.compareValue((short)2, compareBuffer, (short)0, (short)5) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable element + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + //clear the handler + EnvRespHdlr.clear(); + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + compareBuffer = new byte[17] ; + + // Initialise compare buffer + compareBuffer[0] = 4; + for (short i=1; i<17; i++) + compareBuffer[i] = (byte)(i-1) ; + + EnvRespHdlr.clear(); + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,compareBuffer,(short) 0x00, (short) 17); + + // Search Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)0x01) ; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 13 : Successfull call + testCaseNb = (byte) 13 ; + bRes = false ; + + compareBuffer[16] = (byte)0x10 ; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)17)==-1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 14 : Successfull call + testCaseNb = (byte) 14 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer[0] = (byte)0x03; + compareBuffer[16] = (byte)0x0F; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)0, compareBuffer, (short)0, (short)17)==+1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Successfull call + testCaseNb = (byte) 15 ; + bRes = false ; + + compareBuffer = new byte[134]; + // Initialise compareBuffer + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0x55); + Util.arrayCopyNonAtomic(ref_data, (short)2, compareBuffer, (short)3, (short)0x81); + + //Initialise the TLV + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,ref_data,(short) 0x00, (short)0x83); + + // Search Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)0x01) ; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)2, compareBuffer, (short)3, (short)0x81)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 16 : Successfull call + testCaseNb = (byte) 16 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer[131] = (byte) 0x84 ; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)2, compareBuffer, (short)3, (short)0x81)==-1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Successfull call + testCaseNb = (byte) 17 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer[131] = (byte) 0x82 ; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)2, compareBuffer, (short)3, (short)0x81)==+1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 18 : Successfull call (with the length = 0 and the offset = length of the comparaison buffer) + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + // Compare TLV + if(EnvRespHdlr.compareValue((short)2, compareBuffer, (short)compareBuffer.length, (short)0)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 19 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.compareValue((short)0, compareBuffer, (short)compareBuffer.length, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes = true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/Test_Api_2_Erh_Cprv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/Test_Api_2_Erh_Cprv.java new file mode 100644 index 0000000000000000000000000000000000000000..c73c0e9186b7bda2b7a907dfad65989c1e9a0f6e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/Test_Api_2_Erh_Cprv.java @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Cprv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_cprv; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_cprv + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Cprv extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_cprv"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Cprv() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 19 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "13CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4df4273cb0212d4ddc69f079902b9510cbd2e677 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_cprv.Api_2_Erh_Cprv_1 +uicc.test.toolkit.api_2_erh_cprv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/javacard/api_2_erh_cprv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/javacard/api_2_erh_cprv.cap new file mode 100644 index 0000000000000000000000000000000000000000..3ecfdafc94ea990dda8db3de546513d3b16e1fc5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cprv/javacard/api_2_erh_cprv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/Api_2_Erh_Cpyv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/Api_2_Erh_Cpyv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..2d5b4644fb5974d4e928c903040405b49b4d99c7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/Api_2_Erh_Cpyv_1.java @@ -0,0 +1,423 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Cpyv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_cpyv; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_cpyv + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Cpyv_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] ref_data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Cpyv_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Cpyv_1 thisApplet = new Api_2_Erh_Cpyv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Null as dstBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + byte[] dstBuffer = new byte[5] ; + + byte[] data = new byte[16]; + + //initialize the buffer + for(short i=0;i<16;i++) + data[i]=(byte)i; + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 16); + + // Select TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + try { + EnvRespHdlr.copyValue((short)0, null, (short)0, (short)1) ; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : dstOffset >= dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)5, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)0, (short)6) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)3, (short)3) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)0, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= TLV Length + testCaseNb = (byte) 7 ; + bRes = false ; + + dstBuffer = new byte[15] ; + + //built the first tlv + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 6); + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + try { + EnvRespHdlr.copyValue((short)6, dstBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)-1, dstBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : dstLength > TLV length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)0, (short)7) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + dstLength > TLV length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + EnvRespHdlr.copyValue((short)2, dstBuffer, (short)0, (short)5) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable element (the envelopeResponseHandler is cleared) + testCaseNb = (byte) 11 ; + bRes = false ; + + EnvRespHdlr.clear() ; + + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + dstBuffer = new byte[17] ; + + EnvRespHdlr.appendTLV((byte)0x0D,(byte)4,data,(short) 0x00, (short) 0x10); + + // Search the TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)0x01) ; + + try { + // Copy TLV + if(EnvRespHdlr.copyValue((short)0, dstBuffer, (short)0, (short)17)==(short)17) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + byte[] compareBuffer = new byte[20] ; + + // Initialise compare buffer + compareBuffer[0] = 4; + for (short i=1; i<17; i++) + compareBuffer[i] = (byte)(i-1) ; + + try { + if(Util.arrayCompare(dstBuffer, (short)0, compareBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successfull call + testCaseNb = (byte) 14 ; + bRes = false ; + + dstBuffer = new byte[134] ; + //initialise the destination array + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)dstBuffer.length,(byte)0x55); + + // Initialise the TLV + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,ref_data,(short) 0x00, (short)0x83); + + // Search the TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)0x01) ; + + try { + // Copy TLV + if(EnvRespHdlr.copyValue((short)2, dstBuffer, (short)3, (short)0x81)== (short)0x84) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Compare buffer + testCaseNb = (byte) 15 ; + bRes = false ; + + // Initialise compare buffer + compareBuffer = new byte[134]; + Util.arrayFillNonAtomic(compareBuffer,(short)0,(short)compareBuffer.length,(byte)0x55); + Util.arrayCopy(ref_data, (short)2, compareBuffer, (short)3, (short)0x81); + + try { + if(Util.arrayCompare(dstBuffer, (short)0, compareBuffer, (short)0, (short)compareBuffer.length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 16 : Successfull call(with the length = 0 and the offset = length of the destination buffer) + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + // Copy TLV + if(EnvRespHdlr.copyValue((short)2, dstBuffer, (short)dstBuffer.length, (short)0)== (short)dstBuffer.length) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : ToolkitException HANDLER_NO_AVAILABLE + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.copyValue((short)0, dstBuffer, (short)0, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/Test_Api_2_Erh_Cpyv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/Test_Api_2_Erh_Cpyv.java new file mode 100644 index 0000000000000000000000000000000000000000..ee6fad64ff3297450ad8df198007293704ce4b4d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/Test_Api_2_Erh_Cpyv.java @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Cpyv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_cpyv; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_cpyv + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Cpyv extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_cpyv"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Cpyv() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 17 + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "11CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6b5d019a22b0a57ce1907ff084938f448620fef1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_cpyv.Api_2_Erh_Cpyv_1 +uicc.test.toolkit.api_2_erh_cpyv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/javacard/api_2_erh_cpyv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/javacard/api_2_erh_cpyv.cap new file mode 100644 index 0000000000000000000000000000000000000000..3fb6ed26f2ea06a2175b0246f08905ee227df6f5 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_cpyv/javacard/api_2_erh_cpyv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/Api_2_Erh_Facrb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/Api_2_Erh_Facrb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..2319d29cef605d6fbed3c417e3b6b2c88ecfd630 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/Api_2_Erh_Facrb_Bs_1.java @@ -0,0 +1,467 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Facrb_Bs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facrb_bs; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facrb_bs + * + * @version 0.0.1 - 7 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Facrb_Bs_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] ref_data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Facrb_Bs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Facrb_Bs_1 thisApplet = new Api_2_Erh_Facrb_Bs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Null as compareBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + byte[] TLVBuffer=new byte[20]; + byte[] dstBuffer=new byte[20]; + + try { + //initialize the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 16); + + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, null, (short)0) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : compareOffset >= compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short) 20) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareOffset + length > compareBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)5) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : length > compareBufferLength + testCaseNb = (byte) 5 ; + bRes = false ; + + + try { + try { + byte[] compareBuffer=new byte[15]; + EnvRespHdlr.findAndCompareValue((byte)0x0D, compareBuffer, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Unavailable element + testCaseNb = (byte) 6 ; + bRes = false ; + + + // Initialise handler + EnvRespHdlr.clear(); + //built the first tlv + EnvRespHdlr.appendTLV((byte)TAG_DEVICE_IDENTITIES,TLVBuffer,(short) 0x00, (short) 2); + + // Select a TLV + EnvRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + // Search a wrong TLV + try { + EnvRespHdlr.findAndCompareValue((byte)0x03, TLVBuffer, (short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : verify the current TLV + testCaseNb = (byte) 7 ; + bRes = false ; + + // Verify there is no selected TLV + try { + EnvRespHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + // Initialise handler + EnvRespHdlr.clear(); + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)0)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Verify current TLV + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + if(EnvRespHdlr.getValueLength()==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successful call + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise compare buffer + TLVBuffer[16] = (byte)0x10; + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)0)==-1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successful call + testCaseNb = (byte) 11 ; + bRes = false ; + + // Initialise compare buffer + TLVBuffer[16] = (byte)0x0F; + TLVBuffer[0] = (byte)0x03; + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)0)==1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successful call + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise compare buffer + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + for(short i=3;i<20;i++) + TLVBuffer[i]=(byte)(i-3); + TLVBuffer[2]=(byte)4; + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)2)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successful call with 2 Text String TLV + testCaseNb = (byte) 13 ; + bRes = false ; + + EnvRespHdlr.clear(); + // Append the first Text String TLV + EnvRespHdlr.appendTLV((byte)0x0D,ref_data,(short) 0x00, (short)0x81); + + try { + + // Initialise compare buffer + TLVBuffer[0] = (byte) 0x00 ; + TLVBuffer[1] = (byte) 0x11 ; + TLVBuffer[2] = (byte) 0x22 ; + TLVBuffer[3] = (byte) 0x33 ; + TLVBuffer[4] = (byte) 0x44 ; + TLVBuffer[5] = (byte) 0x55 ; + EnvRespHdlr.appendTLV((byte)0x0D, TLVBuffer, (short)0, (short)6) ; + + // Initialise compare buffer + TLVBuffer = new byte[134]; + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + Util.arrayCopyNonAtomic(ref_data,(short)0,TLVBuffer,(short)3,(short)0x81); + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)3)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successful call with 2 Text String TLV + testCaseNb = (byte) 14 ; + bRes = false ; + + // Initialise compare buffer + TLVBuffer[130] = (byte)0x7F; + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)3)==(short)-1) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Successful call with 2 Text String TLV + testCaseNb = (byte) 15 ; + bRes = false ; + + // Initialise compare buffer + TLVBuffer[130] = (byte)0x80; + TLVBuffer[131] = (byte)0x80; + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, TLVBuffer, (short)3)==1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 16 : Successful call : search tag 8Dh + testCaseNb = (byte) 16 ; + bRes = false ; + + TLVBuffer=new byte[17]; + // Initialise compare buffer + for(short i=0;i<17;i++) + TLVBuffer[i]=(byte)(i); + TLVBuffer[0]=(byte)4; + + + try { + + EnvRespHdlr.clear(); + //add the first tag + EnvRespHdlr.appendTLV((byte)0x0D, TLVBuffer , (short)0, (short)17) ; + + // Search tag 8Dh + if(EnvRespHdlr.findAndCompareValue((byte)0x8D, TLVBuffer, (short)0)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Successful call : search tag 8Fh + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + //add the first tag + EnvRespHdlr.appendTLV((byte)0x0F, TLVBuffer , (short)1, (short)16) ; + + //initilase the compare buffer + for(short i=1;i<17;i++) + TLVBuffer[(short)(i-1)]=TLVBuffer[i]; + + // Search tag 8Fh + if(EnvRespHdlr.findAndCompareValue((byte)0x8F, TLVBuffer, (short)0)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 18 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.findAndCompareValue((byte)0, dstBuffer, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes = true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/Test_Api_2_Erh_Facrb_Bs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/Test_Api_2_Erh_Facrb_Bs.java new file mode 100644 index 0000000000000000000000000000000000000000..289f21085f09ec21886ea209980a9a4a9a6ba774 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/Test_Api_2_Erh_Facrb_Bs.java @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Facrb_Bs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facrb_bs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facrb_bs + * + * @version 0.0.1 - 7 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Facrb_Bs extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_facrb_bs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Facrb_Bs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 18 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "12CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..75b9350fdcb166856d48f6bf1342238fb35435d2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_facrb_bs.Api_2_Erh_Facrb_Bs_1 +uicc.test.toolkit.api_2_erh_facrb_bs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/javacard/api_2_erh_facrb_bs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/javacard/api_2_erh_facrb_bs.cap new file mode 100644 index 0000000000000000000000000000000000000000..b60749f2ae410dd03a7ccc21b436c8bceb0ca6c2 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrb_bs/javacard/api_2_erh_facrb_bs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/Api_2_Erh_Facrbbs_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/Api_2_Erh_Facrbbs_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..596f3a0c36068283e564760a61a2ec0e2416e563 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/Api_2_Erh_Facrbbs_Bss_1.java @@ -0,0 +1,642 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Facrbbs_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facrbbs_bss; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facrbbs_bss + * + * @version 0.0.1 - 8 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Facrbbs_Bss_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] ref_data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Facrbbs_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Facrbbs_Bss_1 thisApplet = new Api_2_Erh_Facrbbs_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Null as compareBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + byte[] compareBuffer5=new byte[5]; + byte[] TLVBuffer=new byte[20]; + + try { + // initialise the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte) 1, (short) 0, null, (short) 0, (short) 1) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : compareOffset >= compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer5, (short)5, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer5, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareLength > compareBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer5, (short)0, (short)6) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : compareOffset + compareLength > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer5, (short)3, (short)3) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compareLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0 , compareBuffer5, (short)0 , (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + byte[] compareBuffer15=new byte[15]; + try { + + // initialise the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + //built the first tlv + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 6); + + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)6, compareBuffer15, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)-1, compareBuffer15, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : compareLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer15, (short)0, (short)7) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + compareLength > Text String Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)2, compareBuffer15, (short)0, (short)5) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Invalid parameter + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)0, (short)0, compareBuffer15, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Unavailable Element + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise the handler + EnvRespHdlr.appendTLV((byte)0x02,TLVBuffer,(short) 0x00, (short) 2); + + // Select a TLV + EnvRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + // FindAndCompareValue + try { + EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)2, (short)0, compareBuffer15, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : verify the current TLV + testCaseNb = (byte) 13 ; + bRes = false ; + + // Verify there is no selected TLV + try { + EnvRespHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 14 : Successful call + testCaseNb = (byte) 14 ; + bRes = false ; + + byte[] compareBuffer17=new byte[17]; + + try { + + // initialise the buffer + for(short i=1;i<17;i++) { + compareBuffer17[i]=(byte)(i-1); + TLVBuffer[i]=(byte)(i-1); + } + TLVBuffer[0]=(byte)4; + compareBuffer17[0]=(byte)4; + + //built the first tlv + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer17, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Verify current TLV + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + if(EnvRespHdlr.getValueLength()==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successful call + testCaseNb = (byte) 16; + bRes = false ; + + try { + // Initialise buffers + compareBuffer17[16] = 0x10 ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer17, (short)0, (short)17)==-1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 17 : Successful call + testCaseNb = (byte) 17; + bRes = false ; + + try { + // Initialise buffers + compareBuffer17[16] = 0x0F ; + compareBuffer17[0] = 0x03 ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, compareBuffer17, (short)0, (short)17)==+1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successful call + testCaseNb = (byte) 18; + bRes = false ; + + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,ref_data,(short)0,(short)0x81); + TLVBuffer = new byte[134]; + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + Util.arrayCopyNonAtomic(ref_data,(short)0,TLVBuffer,(short)3,(short)0x81); + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, TLVBuffer, (short)3, (short)0x81)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 19 : Successful call + testCaseNb = (byte) 19; + bRes = false ; + + try { + // Initialise buffers + TLVBuffer[130]=(byte)0x7F ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, TLVBuffer, (short)3, (short)0x81)==-1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 20 : Successful call + testCaseNb = (byte) 20; + bRes = false ; + + try { + // Initialise buffers + TLVBuffer[130]=(byte)0x80 ; + TLVBuffer[131]=(byte)0x80 ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, TLVBuffer, (short)3, (short)0x81)==+1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 21 : Successful call + testCaseNb = (byte)21 ; + bRes = false ; + + try { + + // Append a 2nd Text String TLV + TLVBuffer[0] = (byte)0x00 ; + TLVBuffer[1] = (byte)0x11 ; + TLVBuffer[2] = (byte)0x22 ; + TLVBuffer[3] = (byte)0x33 ; + TLVBuffer[4] = (byte)0x44 ; + TLVBuffer[5] = (byte)0x55 ; + + EnvRespHdlr.appendTLV((byte)0x0D, TLVBuffer, (short)0, (short)6) ; + + // initialise the buffer + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + Util.arrayCopyNonAtomic(ref_data,(short)0,TLVBuffer,(short)3,(short)0x81); + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)1, (short)0, TLVBuffer, (short)3, (short)0x81)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : Successful call + testCaseNb = (byte)22 ; + bRes = false ; + + try { + + // Append a 2nd Text String TLV + TLVBuffer[0] = (byte)0x00 ; + TLVBuffer[1] = (byte)0x11 ; + TLVBuffer[2] = (byte)0x22 ; + TLVBuffer[3] = (byte)0x33 ; + TLVBuffer[4] = (byte)0x44 ; + TLVBuffer[5] = (byte)0x55 ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)2, (short)0, TLVBuffer, (short)0, (short)6)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 23 : Successful call + testCaseNb = (byte)23 ; + bRes = false ; + + try { + // Initialise buffers + TLVBuffer[5] = (byte)0x66 ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x0D, (byte)2, (short)0, TLVBuffer, (short)0, (short)6)==-1) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 24 : Successful call : search tag 8Dh + testCaseNb = (byte) 24 ; + bRes = false ; + + TLVBuffer = new byte[17]; + try { + // initialise the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D, TLVBuffer, (short)0, (short)17) ; + + if(EnvRespHdlr.findAndCompareValue((byte)0x8D, (byte)1, (short)0, TLVBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 25 : Successful call : search tag 8Fh + testCaseNb = (byte) 25 ; + bRes = false ; + + byte[] compareBuffer16=new byte[16]; + + try { + // Append tag 0Fh + EnvRespHdlr.appendTLV((byte)0x0F, TLVBuffer, (short)1, (short)16) ; + + for(short i=0;i<16;i++) + TLVBuffer[i]=TLVBuffer[(short)(i+1)]; + + if(EnvRespHdlr.findAndCompareValue((byte)0x8F, (byte)1, (short)0, TLVBuffer, (short)0, (short)16)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 26 : Successful call (with the length = 0 and the offset = length of the comparaison buffer) + testCaseNb = (byte) 26 ; + bRes = false ; + + try { + if(EnvRespHdlr.findAndCompareValue((byte)0x8F, (byte)1, (short)0, TLVBuffer, (short)TLVBuffer.length, (short)0)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 27 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 27 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.findAndCompareValue((byte)0x8F, (byte)1, (short)0, TLVBuffer, (short)0x0F, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes = true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/Test_Api_2_Erh_Facrbbs_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/Test_Api_2_Erh_Facrbbs_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..985c718c4f19763c310a3d4787d1abad2340ba04 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/Test_Api_2_Erh_Facrbbs_Bss.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Facrbbs_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facrbbs_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facrbbs_bss + * + * @version 0.0.1 - 8 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Facrbbs_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_facrbbs_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Facrbbs_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 27 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "1BCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b2723893af8147c12210ceb27d4141f2cdc37c54 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_facrbbs_bss.Api_2_Erh_Facrbbs_Bss_1 +uicc.test.toolkit.api_2_erh_facrbbs_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/javacard/api_2_erh_facrbbs_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/javacard/api_2_erh_facrbbs_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..c475877806eab217f7094af0360b76ce6bffcb86 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facrbbs_bss/javacard/api_2_erh_facrbbs_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/Api_2_Erh_Facyb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/Api_2_Erh_Facyb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e6ac2c041e7f393cbe1b7b78e0cc51df8b523f93 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/Api_2_Erh_Facyb_Bs_1.java @@ -0,0 +1,444 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Facyb_Bs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facyb_bs; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facyb_bs + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Facyb_Bs_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] ref_data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Facyb_Bs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Facyb_Bs_1 thisApplet = new Api_2_Erh_Facyb_Bs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of tests + boolean bRes; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Null as dstBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + byte[] TLVBuffer=new byte[20]; + byte[] dstBuffer=new byte[20]; + + try { + //initialize the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + //built the first TLV + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 16); + + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, null, (short)0) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : dstOffset >= dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)20) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstOffset + length > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)5) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : length > dstBufferLength + testCaseNb = (byte) 5 ; + bRes = false ; + + dstBuffer=new byte[15]; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Unavailable element + testCaseNb = (byte) 6 ; + bRes = false ; + + TLVBuffer[0]=(byte)11; + TLVBuffer[1]=(byte)22; + + EnvRespHdlr.clear(); + //built the first tlv + EnvRespHdlr.appendTLV((byte)TAG_DEVICE_IDENTITIES,TLVBuffer,(short) 0x00, (short) 2); + + // Select a TLV + EnvRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + try { + EnvRespHdlr.findAndCopyValue((byte)0x03, dstBuffer, (short)0) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false; + } + + // Verify there is no current TLV + try { + EnvRespHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes &= (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + dstBuffer=new byte[20]; + try { + //initialize the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + //built the second TLV + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)0)==(short)17) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Compare buffer + testCaseNb = (byte) 8 ; + bRes = false ; + try { + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 9 : Successful call + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + // Initialise dstBuffer + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)dstBuffer.length,(byte)0x55); + + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)2)==(short)19) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Compare buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise compareBuffer + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + TLVBuffer[2] = (byte)4; + for (short i=3; i<19; i++) + TLVBuffer[i] = (byte)(i-3); + + try { + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)20)==(short)0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 11 : Successful call with 2 Text String TLV + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + + TLVBuffer[2] = (byte)4; + for (short i=3; i<19; i++) + TLVBuffer[i] = (byte)(i-3); + + //built the first TLV + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + //built the second TLV + EnvRespHdlr.appendTLV((byte)0x0D,(byte)0x11); + + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, dstBuffer, (short)0)==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Compare buffer + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successful call, tag = 8Dh + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + if(EnvRespHdlr.findAndCopyValue((byte)0x8D, dstBuffer, (short)0)==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Compare buffer + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Successful call, tag = 8Fh + testCaseNb = (byte) 15 ; + bRes = false ; + + dstBuffer = new byte[131]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)dstBuffer.length,(byte)0x55); + + try { + // Append TLV with tag 0Fh + EnvRespHdlr.appendTLV((byte)0x0F,ref_data,(short) 0x00, (short) 0x80); + + // Search tag 8Fh + if(EnvRespHdlr.findAndCopyValue((byte)0x8F, dstBuffer, (short)3)==(short)0x83) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Compare buffer (with the length = 0 and the offset = length of the destination buffer) + testCaseNb = (byte) 16 ; + bRes = false ; + + // Initialise the comparison buffer + TLVBuffer = new byte [131]; + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + Util.arrayCopyNonAtomic(ref_data,(short)0,TLVBuffer,(short)3,(short)0x80); + + try { + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)dstBuffer.length)==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 17 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.findAndCopyValue((byte)0x8F, dstBuffer, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes = true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/Test_Api_2_Erh_Facyb_Bs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/Test_Api_2_Erh_Facyb_Bs.java new file mode 100644 index 0000000000000000000000000000000000000000..e8afd5e4aef263c3c9fbded4d6434e029b340deb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/Test_Api_2_Erh_Facyb_Bs.java @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +//Test_Api_Erh_Facyb_Bs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facyb_bs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facyb_bs + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Facyb_Bs extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_facyb_bs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Facyb_Bs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 17 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "11CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6cde6e2257d1bd20c74c738601131a3f52022df1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_facyb_bs.Api_2_Erh_Facyb_Bs_1 +uicc.test.toolkit.api_2_erh_facyb_bs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/javacard/api_2_erh_facyb_bs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/javacard/api_2_erh_facyb_bs.cap new file mode 100644 index 0000000000000000000000000000000000000000..1c13131d452497dd9fd7dfea494e53d1ae61333e Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facyb_bs/javacard/api_2_erh_facyb_bs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/Api_2_Erh_Facybbs_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/Api_2_Erh_Facybbs_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6ef6c5364c478fa151d104b6b61af20ccf15b92f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/Api_2_Erh_Facybbs_Bss_1.java @@ -0,0 +1,637 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Facybbs_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facybbs_bss; + +import javacard.framework.Util; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facybbs_bss + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Facybbs_Bss_1 extends TestToolkitApplet { + + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] ref_data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Facybbs_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Facybbs_Bss_1 thisApplet = new Api_2_Erh_Facybbs_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes, bRes2 ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Null as dstBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + byte[] TLVBuffer=new byte[20]; + byte[] dstBuffer=new byte[5]; + + try { + //initialize the buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 16); + + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (byte)0, null, (byte)0, (byte)1) ; + + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : dstOffset >= dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (byte)0, dstBuffer, (byte)5, (byte)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (byte)0, dstBuffer, (byte)-1, (byte)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)0, dstBuffer, (short)0, (short)6) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)0, dstBuffer, (short)3, (short)3) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)0, dstBuffer, (short)0, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + dstBuffer=new byte[15]; + + try { + // Initialise the handler + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 6); + + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)6, dstBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)-1, dstBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : dstLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)0, dstBuffer, (short)0, (short)7) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + dstLength > Text String Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)2, dstBuffer, (short)0, (short)5) ; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable Element + testCaseNb = (byte) 11 ; + bRes = false ; + + // Initialise the handler + EnvRespHdlr.clear(); + TLVBuffer[0]=(byte)0x11; + TLVBuffer[2]=(byte)0x22; + EnvRespHdlr.appendTLV((byte)0x02,TLVBuffer,(short) 0x00, (short) 2); + + // Select a TLV + EnvRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + try { + EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)2, (short)0, dstBuffer, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false; + } + + // Verify there is no current TLV + try { + EnvRespHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes &= (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 12 : Successful call + testCaseNb = (byte) 12 ; + bRes = false ; + dstBuffer = new byte[17]; + + try { + // Initialise buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + // Initialise the handler + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)0, dstBuffer, (short)0, (short)17)==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + if(Util.arrayCompare(TLVBuffer, (short)0, dstBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successful call + testCaseNb = (byte) 14 ; + bRes = false ; + dstBuffer=new byte[20]; + try { + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)dstBuffer.length,(byte)0x55); + + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)2, dstBuffer, (short)3, (short)12)==15) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Compare buffer + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + // Initialise compare buffer + for (short i=3; i<15; i++) + TLVBuffer[i] = (byte)(i-2) ; + + if(Util.arrayCompare(TLVBuffer, (short)0, dstBuffer, (short)0, (short)20)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successful call with 2 Text String TLV + testCaseNb = (byte) 16 ; + bRes = false ; + + dstBuffer=new byte[17]; + try { + + TLVBuffer[0] = (byte) 0x00 ; + TLVBuffer[1] = (byte) 0x11 ; + TLVBuffer[2] = (byte) 0x22 ; + TLVBuffer[3] = (byte) 0x33 ; + TLVBuffer[4] = (byte) 0x44 ; + TLVBuffer[5] = (byte) 0x55 ; + + //add a second TLV + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 6); + + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)1, (short)0, dstBuffer, (short)0, (short)17)==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Compare buffer + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + //initialize the compare buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + if(Util.arrayCompare(TLVBuffer, (short)0, dstBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successful call with 2 Text String TLV + testCaseNb = (byte) 18 ; + bRes = false ; + + dstBuffer=new byte[6]; + + try { + if(EnvRespHdlr.findAndCopyValue((byte)0x0D, (byte)2, (short)0, dstBuffer, (short)0, (short)6)==(short)6) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 19 : Compare buffer + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + TLVBuffer[0] = (byte) 0x00 ; + TLVBuffer[1] = (byte) 0x11 ; + TLVBuffer[2] = (byte) 0x22 ; + TLVBuffer[3] = (byte) 0x33 ; + TLVBuffer[4] = (byte) 0x44 ; + TLVBuffer[5] = (byte) 0x55 ; + + if(Util.arrayCompare(TLVBuffer, (short)0, dstBuffer, (short)0, (short)6)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 20 : Successful call, tag = 8Dh + testCaseNb = (byte) 20 ; + bRes = false ; + + dstBuffer=new byte[17]; + + //initialize the compare buffer + for(short i=1;i<17;i++) + TLVBuffer[i]=(byte)(i-1); + TLVBuffer[0]=(byte)4; + + try { + // Initialise handler + EnvRespHdlr.clear(); + //add the first TLV + EnvRespHdlr.appendTLV((byte)0x0D,TLVBuffer,(short) 0x00, (short) 17); + + if(EnvRespHdlr.findAndCopyValue((byte)0x8D, (byte)1, (short)0, dstBuffer, (short)0, (short)17)==(short)17) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 21 : Compare buffer + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)17)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : Successful call, tag = 8Fh + testCaseNb = (byte) 22 ; + bRes = false ; + + dstBuffer = new byte[131]; + Util.arrayFillNonAtomic(dstBuffer,(short)0,(short)dstBuffer.length,(byte)0x55); + + try { + + // Append TLV with tag 0Fh + EnvRespHdlr.appendTLV((byte)0x0F,ref_data,(short) 0x00, (short) 0x80); + + // Search tag 8Fh + if(EnvRespHdlr.findAndCopyValue((byte)0x8F, (byte)1, (short)0, dstBuffer, (short)0, (short)0x80)==(short)0x80) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 23 : Compare buffer + testCaseNb = (byte) 23 ; + bRes = false ; + + // Initialise the comparison buffer + TLVBuffer = new byte [131]; + Util.arrayFillNonAtomic(TLVBuffer,(short)0,(short)TLVBuffer.length,(byte)0x55); + Util.arrayCopyNonAtomic(ref_data,(short)0,TLVBuffer,(short)0,(short)0x80); + + try { + + if(Util.arrayCompare(TLVBuffer, (short)0,dstBuffer, (short)0, (short)dstBuffer.length)==0) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 24 : Successful call (with the length = 0 and the offset = length of the comparaison buffer) + testCaseNb = (byte) 24 ; + bRes = false ; + + try { + // Search tag 8Fh + if(EnvRespHdlr.findAndCopyValue((byte)0x8F, (byte)0x01, (short)0, dstBuffer, (short)dstBuffer.length, (short)0)==(short)dstBuffer.length) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 25 : BAD INPUT PARAMETER, occurence = 0 + testCaseNb = (byte) 25 ; + bRes = false ; + + try { + try { + EnvRespHdlr.findAndCopyValue((byte)0x8F, (byte)0, (short)0, dstBuffer, (short)0, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) { + bRes = true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 26 : ToolkitException HANDLER_NOT_AVAILABLE + testCaseNb = (byte) 26 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.findAndCopyValue((byte)0x8F, (byte)1, (short)0, dstBuffer, (short)0, (short)0); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes = true; + } else { + bRes = false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/Test_Api_2_Erh_Facybbs_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/Test_Api_2_Erh_Facybbs_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..1f3276f493e5a722cb8c492ee5f82c09f771bf7a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/Test_Api_2_Erh_Facybbs_Bss.java @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Facybbs_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_facybbs_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_facybbs_bss + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Facybbs_Bss extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_facybbs_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Facybbs_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 26 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "1ACCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ad0a8123963352cdab8f476230ff257805dea1ce --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_facybbs_bss.Api_2_Erh_Facybbs_Bss_1 +uicc.test.toolkit.api_2_erh_facybbs_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/javacard/api_2_erh_facybbs_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/javacard/api_2_erh_facybbs_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..9c030bf2f46e8ffc174de0ccbded4e8ad8fd6050 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_facybbs_bss/javacard/api_2_erh_facybbs_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/Api_2_Erh_Find_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/Api_2_Erh_Find_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1cee9b53a23ca525bea0bf03ab741a264383becc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/Api_2_Erh_Find_1.java @@ -0,0 +1,322 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Find_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_find; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_find + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Find_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Find_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Find_1 thisApplet = new Api_2_Erh_Find_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : invalid input parameter (occurrence = 0) + testCaseNb = (byte) 1 ; + bRes = false ; + + byte[] data = new byte[0x03]; + + //initialize the buffer + data[0]=(byte)11; + data[1]=(byte)22; + data[2]=(byte)33; + + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x81,data,(short) 0x00, (short) 0x03); + + + //initialize the buffer + data[0]=(byte)99; + data[1]=(byte)77; + + //built the second tlv + EnvRespHdlr.appendTLV((byte)0x82,data,(short) 0x00, (short) 0x02); + + try { + EnvRespHdlr.findTLV((byte)0x01, (byte) 0x00) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Search 1st TLV + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + if(EnvRespHdlr.findTLV((byte)0x01, (byte) 0x01)==TLV_FOUND_CR_SET) + bRes =true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Verify selected TLV + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + if((short)0x03==EnvRespHdlr.getValueLength()) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Search 2nd TLV + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + if(EnvRespHdlr.findTLV((byte)0x02, (byte) 0x01)==TLV_FOUND_CR_SET) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Verify selected TLV + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + if((short)0x02==EnvRespHdlr.getValueLength()) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Search a wrong tag + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + // Select a correct TLV + EnvRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)0x02) ; + if(EnvRespHdlr.findTLV((byte)0x03, (byte) 0x01)==TLV_NOT_FOUND) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Verify the current TLV is no longer defined + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + if(EnvRespHdlr.getValueLength()==0) + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Search a tag with a wrong occurence + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + if(EnvRespHdlr.findTLV((byte)0x01, (byte) 0x02)==TLV_NOT_FOUND) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Verify the current TLV is no longer defined + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + if(EnvRespHdlr.getValueLength()==0) + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Search a TLV with occurence=2 + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + // Append Tag 0x02 + EnvRespHdlr.appendTLV((byte)0x02, (byte)0x00) ; + // Search the tag + if(EnvRespHdlr.findTLV((byte)0x02, (byte) 0x02)==TLV_FOUND_CR_NOT_SET) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Search a TLV + testCaseNb = (byte) 11 ; + bRes = false ; + try { + // Append Tag 0x04 + EnvRespHdlr.appendTLV((byte)0x04, (byte)0x00) ; + + // Search the tag + if(EnvRespHdlr.findTLV((byte)0x04, (byte) 0x01)==TLV_FOUND_CR_NOT_SET) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Search tag 81h + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + // Search the tag + if(EnvRespHdlr.findTLV((byte)0x81, (byte) 0x01)==TLV_FOUND_CR_SET) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Search tag 84h + + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + // Search the tag + if(EnvRespHdlr.findTLV((byte)0x84, (byte) 0x01)==TLV_FOUND_CR_NOT_SET) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : ToolkitException HANDLER_NOT_AVAILABLE + + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.findTLV((byte)0x81, (byte) 0x01); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/Test_Api_2_Erh_Find.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/Test_Api_2_Erh_Find.java new file mode 100644 index 0000000000000000000000000000000000000000..18bc26395083bcda3331fc662fe5c64b6259b718 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/Test_Api_2_Erh_Find.java @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Find.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_find; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_find + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Find extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_find"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Find() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 14 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..e40844d08862a529e2f09934ff227663387d32f8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_find.Api_2_Erh_Find_1 +uicc.test.toolkit.api_2_erh_find +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/javacard/api_2_erh_find.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/javacard/api_2_erh_find.cap new file mode 100644 index 0000000000000000000000000000000000000000..3ccc0c7d59239285be6d735b77df3fcde8a9ed7d Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_find/javacard/api_2_erh_find.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/Api_2_Erh_Gcap_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/Api_2_Erh_Gcap_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1976943477b529aa6a7581efae2831fdc30b534b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/Api_2_Erh_Gcap_1.java @@ -0,0 +1,137 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Gcap_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gcap; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gcap + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Gcap_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] Buffer; + /** + * Constructor of the applet + */ + public Api_2_Erh_Gcap_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Gcap_1 thisApplet = new Api_2_Erh_Gcap_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes; + + // results of methods + short sLength = 0; + short sCapacity = 0; + + // Get the system instance of handlers + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + + // get capacity of the handler + testCaseNb = (byte)0x01; + bRes = false; + try { + sCapacity = envRespHdlr.getCapacity(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + // Fill the handler with the maximum capacity + Buffer = new byte[sCapacity]; + + for (short i=0; i 0x81) && (sCapacity <= 0x102)) + { + envRespHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 3)); + } + else if (sCapacity > 0x102) + { + envRespHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 4)); + } + bRes &= true; + } + catch (Exception e) { + bRes = false; + } + + // clear the handler + try { + envRespHdlr.clear(); + bRes &= true; + } + catch (Exception e) { + bRes = false; + } + + // Fill the handler with the maximum capacity + 1 + try { + if (sCapacity <= 0x81) + { + envRespHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 1)); + } + else if ((sCapacity > 0x81) && (sCapacity <= 0x102)) + { + envRespHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 2)); + } + else if (sCapacity > 0x102) + { + envRespHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 3)); + } + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.HANDLER_OVERFLOW) + bRes &= true ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/Test_Api_2_Erh_Gcap.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/Test_Api_2_Erh_Gcap.java new file mode 100644 index 0000000000000000000000000000000000000000..da9cfd9d3f0199c1202f6196969f89535e3b5f52 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/Test_Api_2_Erh_Gcap.java @@ -0,0 +1,107 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Gcap.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gcap; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gcap + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Gcap extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_gcap"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Gcap() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "01CC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..dcfc67713ddda09f75199eedbc600df94a92c914 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_gcap.Api_2_Erh_Gcap_1 +uicc.test.toolkit.api_2_erh_gcap +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/javacard/api_2_erh_gcap.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/javacard/api_2_erh_gcap.cap new file mode 100644 index 0000000000000000000000000000000000000000..deef3d2c884bfe474f9470d33b5d52a7aca9f884 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gcap/javacard/api_2_erh_gcap.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/Api_2_Erh_Glen_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/Api_2_Erh_Glen_1.java new file mode 100644 index 0000000000000000000000000000000000000000..17f8bc537b6e578ef985c75ad7da154f18bbc761 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/Api_2_Erh_Glen_1.java @@ -0,0 +1,191 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Glen_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_glen; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_glen + * + * @version 0.0.1 - 5 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Glen_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Glen_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Glen_1 thisApplet = new Api_2_Erh_Glen_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + + switch ( testCaseNb ) { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : length = 0 + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + bRes = (EnvRespHdlr.getLength() == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + return; + + case (byte) 1 : + + // -------------------------------------------- + // Test Case 2 : length = 7 + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + EnvRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x07); + bRes = (EnvRespHdlr.getLength() == (short)9) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + return; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : length = getCapacity() + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short)(EnvRespHdlr.getCapacity()- 3)); + bRes = (EnvRespHdlr.getLength() == (short)EnvRespHdlr.getCapacity()) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + return; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : length = 7Fh + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + EnvRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x7F); + bRes = (EnvRespHdlr.getLength() == (short)0x0081) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + return; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : length = 80h + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + EnvRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x80); + bRes = (EnvRespHdlr.getLength() == (short)0x0083) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + return; + + case (byte)5: + // -------------------------------------------- + // Test Case 6 : ToolkitException HANDLER_NO_AVAILABLE + testCaseNb=(byte)6; + bRes=false; + + try { + EnvRespHdlr.post(true); + try { + EnvRespHdlr.getLength(); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + return; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/Test_Api_2_Erh_Glen.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/Test_Api_2_Erh_Glen.java new file mode 100644 index 0000000000000000000000000000000000000000..645142efcd7ccac5edb0740f6c8b85d21ffdf088 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/Test_Api_2_Erh_Glen.java @@ -0,0 +1,122 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Glen.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_glen; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_glen + * + * @version 0.0.1 - 5 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Glen extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_glen"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Glen() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 + test.unrecognizedEnvelope(); + + // Test case 2 + test.unrecognizedEnvelope(); + + // Test case 3 + test.unrecognizedEnvelope(); + + // Test case 4 + test.unrecognizedEnvelope(); + + // Test case 5 + test.unrecognizedEnvelope(); + + // Test case 6 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..1d9a6ecad301556e0ac3abaa9ba712fc34a4757e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_glen.Api_2_Erh_Glen_1 +uicc.test.toolkit.api_2_erh_glen +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/javacard/api_2_erh_glen.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/javacard/api_2_erh_glen.cap new file mode 100644 index 0000000000000000000000000000000000000000..e4ba602be04d5af7bafc4f14037693c9723da327 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_glen/javacard/api_2_erh_glen.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/Api_2_Erh_Gvby_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/Api_2_Erh_Gvby_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a88bfc108761816d8df5521f2cb3288e5f173ef3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/Api_2_Erh_Gvby_1.java @@ -0,0 +1,261 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Gvby_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gvby; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gvby + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Gvby_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Gvby_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Gvby_1 thisApplet = new Api_2_Erh_Gvby_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + byte[] data = new byte[0xFF]; + + try { + //preparation of the append TLV + data[0]=(byte)0x81; + data[1]=(byte)0x82; + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x82,data,(short) 0x00, (short) 0x02); + + data[0]=(byte)0x11; + data[1]=(byte)0x22; + data[2]=(byte)0xFE; + //built the second TLV + EnvRespHdlr.appendTLV((byte)0x81,data,(short) 0x00, (short) 0x03); + + // Find Text String TLV + if((EnvRespHdlr.findTLV((byte)0x03, (byte)1)==TLV_NOT_FOUND)&& + (EnvRespHdlr.getValueByte((short)0)==0)) + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Out of TLV Boundaries + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + // Find String TLV + if((EnvRespHdlr.findTLV((byte)0x01, (byte)1)==TLV_FOUND_CR_SET)&& + (EnvRespHdlr.getValueByte((short)3)==0)) + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + // Find String TLV + if((EnvRespHdlr.findTLV((byte)0x01, (byte)1)==TLV_FOUND_CR_SET)&& + (EnvRespHdlr.getValueByte((short)2)==(byte)0xFE)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + // Find String TLV + if((EnvRespHdlr.findTLV((byte)0x02, (byte)1)==TLV_FOUND_CR_SET)&& + (EnvRespHdlr.getValueByte((short)0)==(byte)0x81)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + //preparation of the append TLV + for(short i=0;i<0x00FF;i++) + data[i]=(byte)i; + + //built the third TLV + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x7E); + + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET)&& + (EnvRespHdlr.getValueByte((short)0x7D)==(byte)0x7D)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + //built the first TLV + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x80); + + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET)&& + (EnvRespHdlr.getValueByte((short)0x7E)==(byte)0X7E)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET)&& + (EnvRespHdlr.getValueByte((short)0x7F)==(byte)0x7F)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + //preparation of the append TLV + //built the first TLV + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0xF1); + + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET)&& + (EnvRespHdlr.getValueByte((short)0xF0)==(byte)0xF0)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 9 : Successful call + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + //preparation of the append TLV + //built the first TLV + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.getValueByte((short)0); + bRes= false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/Test_Api_2_Erh_Gvby.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/Test_Api_2_Erh_Gvby.java new file mode 100644 index 0000000000000000000000000000000000000000..a2e563b41bd436363e3d2970366943f3bd80326a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/Test_Api_2_Erh_Gvby.java @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Gvby.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gvby; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gvby + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Gvby extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_gvby"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Gvby() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 9 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "09CCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7d68d0ee9b6ef9ffa3eb95099f2ab291ed514181 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_gvby.Api_2_Erh_Gvby_1 +uicc.test.toolkit.api_2_erh_gvby +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/javacard/api_2_erh_gvby.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/javacard/api_2_erh_gvby.cap new file mode 100644 index 0000000000000000000000000000000000000000..20fa9859d13db6cf580085a724da3abc6da7d687 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvby/javacard/api_2_erh_gvby.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/Api_2_Erh_Gvle_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/Api_2_Erh_Gvle_1.java new file mode 100644 index 0000000000000000000000000000000000000000..74a21edcd3480d9a47ce043b929d2e57bf5c75e9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/Api_2_Erh_Gvle_1.java @@ -0,0 +1,228 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Gvle_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gvle; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gvle + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Gvle_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Erh_Gvle_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Gvle_1 thisApplet = new Api_2_Erh_Gvle_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + // prepare the TLV before updating + byte[] data=new byte[0xFF]; + for( short i=0;i<(short)0xFF;i++) + data[i]=(byte)2; + + try { + + //append tlv and find a bad TLV + EnvRespHdlr.appendTLV((byte)0x33,data,(short) 0x00, (short) 0x04); + EnvRespHdlr.findTLV((byte)0x03,(byte)1) ; + EnvRespHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Successful call with length=0 + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + //append tlv with a length of 0 + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x00); + // Search the TLV + if( (EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET) + && (EnvRespHdlr.getValueLength()==0)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call with length=2 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + // clear the handler and append TLV with the new + EnvRespHdlr.clear(); + //append tlv with a length of 02 + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x02); + // Search Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + // Get length + if(EnvRespHdlr.getValueLength()==2) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call with length=0x7F + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + // clear the handler and append TLV with the new + EnvRespHdlr.clear(); + + //append tlv with a length of 7F + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x7F); + + // Search Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + if(EnvRespHdlr.getValueLength()==0x7F) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successful call with length=0x80 + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + // clear the handler and append TLV with the new + EnvRespHdlr.clear(); + + //append tlv with a length of 80 + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x80); + + // Search Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + if(EnvRespHdlr.getValueLength()==0x80) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call with length=0xF1 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + // clear the handler and append TLV with the new + EnvRespHdlr.clear(); + + //append tlv with a length of FA + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0xFA); + + // Search Text String TLV + EnvRespHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + if(EnvRespHdlr.getValueLength()==0xFA) + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : ToolkitException HANDLER_NO_AVAILABLE + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.getValueLength(); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/Test_Api_2_Erh_Gvle.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/Test_Api_2_Erh_Gvle.java new file mode 100644 index 0000000000000000000000000000000000000000..a4d8765062129f08c3c768fbb8e6f74b6378ccfb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/Test_Api_2_Erh_Gvle.java @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Gvle.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gvle; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gvle + * + * @version 0.0.1 - 6 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Gvle extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_gvle"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Gvle() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 7 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "07CCCCCC CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..8e6c2bf51b0f08d9ebedb4ce2698ccfe7ea51577 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_gvle.Api_2_Erh_Gvle_1 +uicc.test.toolkit.api_2_erh_gvle +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/javacard/api_2_erh_gvle.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/javacard/api_2_erh_gvle.cap new file mode 100644 index 0000000000000000000000000000000000000000..b3b32a808f90ce54f4f4bd51661ea783b9b67579 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvle/javacard/api_2_erh_gvle.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/Api_2_Erh_Gvsh_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/Api_2_Erh_Gvsh_1.java new file mode 100644 index 0000000000000000000000000000000000000000..654f8fa94d4ee45680f2bc53f214805c678ec169 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/Api_2_Erh_Gvsh_1.java @@ -0,0 +1,259 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Gvsh_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gvsh; + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gvsh + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Gvsh_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] Buffer; + /** + * Constructor of the applet + */ + public Api_2_Erh_Gvsh_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Gvsh_1 thisApplet = new Api_2_Erh_Gvsh_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event){ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the EnvelopeResponseHandler class + EnvelopeResponseHandler EnvRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + byte[] data=new byte[0xFF]; + + try { + //preparation of the append TLV + data[0]=(byte)0x81; + data[1]=(byte)0x82; + //built the first tlv + EnvRespHdlr.appendTLV((byte)0x82,data,(short) 0x00, (short) 0x02); + + data[0]=(byte)0x11; + data[1]=(byte)0x22; + data[2]=(byte)0xFE; + //built the second TLV + EnvRespHdlr.appendTLV((byte)0x81,data,(short) 0x00, (short) 0x03); + + // Find Text String TLV + if((EnvRespHdlr.findTLV((byte)0x03, (byte)1)==TLV_NOT_FOUND)&& + (EnvRespHdlr.getValueShort((short)0)==0)) + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : Out of TLV Boundaries + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + // Find String TLV + if((EnvRespHdlr.findTLV((byte)0x01, (byte)1)==TLV_FOUND_CR_SET) + &&(EnvRespHdlr.getValueShort((short)3)==0)) + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + // Find String TLV + if((EnvRespHdlr.findTLV((byte)0x01, (byte)1)==TLV_FOUND_CR_SET) + &&(EnvRespHdlr.getValueShort((short)1)==(short)0x22FE)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + // Find String TLV + if((EnvRespHdlr.findTLV((byte)0x02, (byte)1)==TLV_FOUND_CR_SET) + &&(EnvRespHdlr.getValueShort((short)0)==(short)0x8182)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + //preparation of the append TLV + for(short i=0;i<0x00FF;i++) + data[i]=(byte)i; + + //built the third TLV + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x7E); + + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET) + &&(EnvRespHdlr.getValueShort((short)0x7C)==(short)0x7C7D)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + //built the first TLV + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0x81); + + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET) + &&(EnvRespHdlr.getValueShort((short)0x7D)==(short)0X7D7E)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET) + &&(EnvRespHdlr.getValueShort((short)0x7F)==(short)0x7F80)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + //preparation of the append TLV + //built the first TLV + EnvRespHdlr.clear(); + EnvRespHdlr.appendTLV((byte)0x0D,data,(short) 0x00, (short) 0xF1); + + // get the value byte + if((EnvRespHdlr.findTLV((byte)0x0D, (byte)1)==TLV_FOUND_CR_NOT_SET) + &&(EnvRespHdlr.getValueShort((short)0xEF)==(short)0xEFF0)) + bRes=true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 9 : Successful call + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + //preparation of the append TLV + //built the first TLV + EnvRespHdlr.clear(); + EnvRespHdlr.post(true); + try { + EnvRespHdlr.getValueShort((short)0); + bRes= false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE) { + bRes= true; + } else { + bRes=false; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/Test_Api_2_Erh_Gvsh.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/Test_Api_2_Erh_Gvsh.java new file mode 100644 index 0000000000000000000000000000000000000000..daa3d884ce95ea89f86c069b8ac5b408e04bca31 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/Test_Api_2_Erh_Gvsh.java @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Gvsh.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_gvsh; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.UiccCardManagementService; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_gvsh + * + * @version 0.0.1 - 11 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Gvsh extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_gvsh"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Gvsh() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 to 9 + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "09CCCCCC CCCCCCCC CCCC"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..031878f2331b938c2bfb0e61372f1a3c1301fb2b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_gvsh.Api_2_Erh_Gvsh_1 +uicc.test.toolkit.api_2_erh_gvsh +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/javacard/api_2_erh_gvsh.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/javacard/api_2_erh_gvsh.cap new file mode 100644 index 0000000000000000000000000000000000000000..fba68443e093df9e405fc8351354c0c9d74dedaf Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_gvsh/javacard/api_2_erh_gvsh.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/Api_2_Erh_Poab_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/Api_2_Erh_Poab_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ec414a4aaac3db4c207036e6984f3607b30492a4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/Api_2_Erh_Poab_1.java @@ -0,0 +1,305 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Poab_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_poab; + +import javacard.framework.APDUException; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_poab + * + * @version 0.0.1 - 4 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Poab_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + private static byte[] displayString = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T',(byte)'1'}; + + private static final byte DCS_8_BIT_DATA = 0x04; + /** + * Constructor of the applet + */ + public Api_2_Erh_Poab_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Poab_1 thisApplet = new Api_2_Erh_Poab_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register on EVENT DOWNLOAD CALL CONTROL BY NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : getTheHandler and than post(true) + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + envRespHdlr.postAsBERTLV(true,(byte)0x01); + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : Append data and post(true) + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short)0x00FA); + envRespHdlr.postAsBERTLV(true,(byte)0x33); + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the methode appendTLV after the using of the post(true) methode + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.postAsBERTLV(true,(byte)0x33); + + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + bRes = false; + } + catch (ToolkitException e){ + if(e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) + bRes = true ; + } + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the methode post(FALSE) and send a display text + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.postAsBERTLV(false,(byte)0x75); + + //send the proactive command + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5: use the methode postAsBERTLV() without appendTLV() and send a display text + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + + envRespHdlr.postAsBERTLV(false,(byte)0x33); + + //send the proactive command + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + + bRes = true; + } + + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the postAsBERTLV() methode after a display text command + testCaseNb = (byte) 6 ; + + bRes = false ; + try{ + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x10, (short) 0x0010); + //send the proactive command + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + + try { + envRespHdlr.postAsBERTLV(false,(byte)0x33); + bRes = false; + } + + catch (ToolkitException e){ + if(e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : try to use the methode postAsBERTLV(true) after the using of the methode postAsBERTLV(false) + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.postAsBERTLV(false,(byte)0x56); + bRes = false; + try{ + envRespHdlr.postAsBERTLV(true,(byte)0x28); + } + catch (ToolkitException e){ + if(e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) + bRes = true ; + } + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : In case of CALL_CONTROL the CAT Runtime Environment set the boolean value always to true + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.postAsBERTLV(false,(byte)0x33); + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : In case of CALL_CONTROL the CAT Runtime Environment set the boolean value always to true + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short)0x0010,(short)0x0010); + envRespHdlr.postAsBERTLV(true,(byte)0x28); + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : Resulting response length greater than 256. + testCaseNb = (byte) 10 ; + + bRes = false ; + try { + envRespHdlr.appendArray(data,(short) 0x00,(short)0x00FE); + bRes = false; + try{ + envRespHdlr.postAsBERTLV(true,(byte)0x33); + } + catch (APDUException e){ + if(e.getReason()==APDUException.BAD_LENGTH) + bRes = true ; + } + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/Test_Api_2_Erh_Poab.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/Test_Api_2_Erh_Poab.java new file mode 100644 index 0000000000000000000000000000000000000000..b03462a7fb9b0ace738e193d6c235c01fa781949 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/Test_Api_2_Erh_Poab.java @@ -0,0 +1,184 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Poab.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_poab; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_poab + * + * @version 0.0.1 - 4 avr. 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Poab extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_poab"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Poab() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 + response = test.unrecognizedEnvelope(); + result = response.checkData("0100"); + result &= response.checkSw("9000"); + + // Test case 2 + response = test.unrecognizedEnvelope(); + result &= response.checkData("3381FD" + + "0181FA01 02030405 06070809 0A0B0C0D" + + "0E0F1011 12131415 16171819 1A1B1C1D" + + "1E1F2021 22232425 26272829 2A2B2C2D" + + "2E2F3031 32333435 36373839 3A3B3C3D" + + "3E3F4041 42434445 46474849 4A4B4C4D" + + "4E4F5051 52535455 56575859 5A5B5C5D" + + "5E5F6061 62636465 66676869 6A6B6C6D" + + "6E6F7071 72737475 76777879 7A7B7C7D" + + "7E7F8081 82838485 86878889 8A8B8C8D" + + "8E8F9091 92939495 96979899 9A9B9C9D" + + "9E9FA0A1 A2A3A4A5 A6A7A8A9 AAABACAD" + + "AEAFB0B1 B2B3B4B5 B6B7B8B9 BABBBCBD" + + "BEBFC0C1 C2C3C4C5 C6C7C8C9 CACBCCCD" + + "CECFD0D1 D2D3D4D5 D6D7D8D9 DADBDCDD" + + "DEDFE0E1 E2E3E4E5 E6E7E8E9 EAEBECED" + + "EEEFF0F1 F2F3F4F5 F6F7F8F9 FA"); + + result &= response.checkSw("9000"); + + // Test case 3 + response = test.unrecognizedEnvelope(); + result &= response.checkData("33120110 01020304 05060708 090A0B0C 0D0E0F10"); + result &= response.checkSw("9000"); + + // Test case 4 + response = test.unrecognizedEnvelope(); + result &= response.checkData("75120110 01020304 05060708 090A0B0C 0D0E0F10"); + result &= response.checkSw("6200"); + response = test.envelopeEventDownloadUserActivity(); // Dummy command to get the 91XX status word + result &= response.checkSw("9115"); + response = test.fetch("15"); + result &= response.checkData("D0138103 01218082 0281028D 08044150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + // Test case 5 + response = test.unrecognizedEnvelope(); + result &= response.checkData("3300"); + result &= response.checkSw("6200"); + response = test.envelopeEventDownloadUserActivity(); // Dummy command to get the 91XX status word + result &= response.checkSw("9115"); + response = test.fetch("15"); + result &= response.checkData("D0138103 01218082 0281028D 08044150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + // Test case 6 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9115"); + response = test.fetch("15"); + result &= response.checkData("D0138103 01218082 0281028D 08044150" + + "504C4554 31"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9000"); + + // Test case 7 + response = test.unrecognizedEnvelope(); + result &= response.checkData("56120110 01020304 05060708 090A0B0C 0D0E0F10"); + result &= response.checkSw("6200"); + + // Test case 8 + response = test.envelopeCallControlByNAA(); + result &= response.checkData("33120110 01020304 05060708 090A0B0C 0D0E0F10"); + result &= response.checkSw("9000"); + + // Test case 9 + response = test.envelopeCallControlByNAA(); + result &= response.checkData("28120110 11121314 15161718 191A1B1C 1D1E1F20"); + result &= response.checkSw("9000"); + + // Test case 10 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0ACCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..32e4b12b0c6d26586f8618f03d09c843900aca82 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_poab.Api_2_Erh_Poab_1 +uicc.test.toolkit.api_2_erh_poab +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/javacard/api_2_erh_poab.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/javacard/api_2_erh_poab.cap new file mode 100644 index 0000000000000000000000000000000000000000..78020486ecf8435ade3c5d98f28bb042d319d213 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_poab/javacard/api_2_erh_poab.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/Api_2_Erh_Post_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/Api_2_Erh_Post_1.java new file mode 100644 index 0000000000000000000000000000000000000000..90147b634ac4cbe41a88cb32d891e42f9e2a1d75 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/Api_2_Erh_Post_1.java @@ -0,0 +1,310 @@ +//----------------------------------------------------------------------------- +//Api_2_Erh_Post_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_post; + +import javacard.framework.APDUException; +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_post + * + * @version 0.0.1 - 24 mars 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Erh_Post_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + byte[] data = {(byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0x0A,(byte)0x0B,(byte)0x0C,(byte)0x0D,(byte)0x0E,(byte)0x0F,(byte)0x10, + (byte)0x11,(byte)0x12,(byte)0x13,(byte)0x14,(byte)0x15,(byte)0x16,(byte)0x17,(byte)0x18,(byte)0x19,(byte)0x1A,(byte)0x1B,(byte)0x1C,(byte)0x1D,(byte)0x1E,(byte)0x1F,(byte)0x20, + (byte)0x21,(byte)0x22,(byte)0x23,(byte)0x24,(byte)0x25,(byte)0x26,(byte)0x27,(byte)0x28,(byte)0x29,(byte)0x2A,(byte)0x2B,(byte)0x2C,(byte)0x2D,(byte)0x2E,(byte)0x2F,(byte)0x30, + (byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x3A,(byte)0x3B,(byte)0x3C,(byte)0x3D,(byte)0x3E,(byte)0x3F,(byte)0x40, + (byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4A,(byte)0x4B,(byte)0x4C,(byte)0x4D,(byte)0x4E,(byte)0x4F,(byte)0x50, + (byte)0x51,(byte)0x52,(byte)0x53,(byte)0x54,(byte)0x55,(byte)0x56,(byte)0x57,(byte)0x58,(byte)0x59,(byte)0x5A,(byte)0x5B,(byte)0x5C,(byte)0x5D,(byte)0x5E,(byte)0x5F,(byte)0x60, + (byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66,(byte)0x67,(byte)0x68,(byte)0x69,(byte)0x6A,(byte)0x6B,(byte)0x6C,(byte)0x6D,(byte)0x6E,(byte)0x6F,(byte)0x70, + (byte)0x71,(byte)0x72,(byte)0x73,(byte)0x74,(byte)0x75,(byte)0x76,(byte)0x77,(byte)0x78,(byte)0x79,(byte)0x7A,(byte)0x7B,(byte)0x7C,(byte)0x7D,(byte)0x7E,(byte)0x7F,(byte)0x80, + (byte)0x81,(byte)0x82,(byte)0x83,(byte)0x84,(byte)0x85,(byte)0x86,(byte)0x87,(byte)0x88,(byte)0x89,(byte)0x8A,(byte)0x8B,(byte)0x8C,(byte)0x8D,(byte)0x8E,(byte)0x8F,(byte)0x90, + (byte)0x91,(byte)0x92,(byte)0x93,(byte)0x94,(byte)0x95,(byte)0x96,(byte)0x97,(byte)0x98,(byte)0x99,(byte)0x9A,(byte)0x9B,(byte)0x9C,(byte)0x9D,(byte)0x9E,(byte)0x9F,(byte)0xA0, + (byte)0xA1,(byte)0xA2,(byte)0xA3,(byte)0xA4,(byte)0xA5,(byte)0xA6,(byte)0xA7,(byte)0xA8,(byte)0xA9,(byte)0xAA,(byte)0xAB,(byte)0xAC,(byte)0xAD,(byte)0xAE,(byte)0xAF,(byte)0xB0, + (byte)0xB1,(byte)0xB2,(byte)0xB3,(byte)0xB4,(byte)0xB5,(byte)0xB6,(byte)0xB7,(byte)0xB8,(byte)0xB9,(byte)0xBA,(byte)0xBB,(byte)0xBC,(byte)0xBD,(byte)0xBE,(byte)0xBF,(byte)0xC0, + (byte)0xC1,(byte)0xC2,(byte)0xC3,(byte)0xC4,(byte)0xC5,(byte)0xC6,(byte)0xC7,(byte)0xC8,(byte)0xC9,(byte)0xCA,(byte)0xCB,(byte)0xCC,(byte)0xCD,(byte)0xCE,(byte)0xCF,(byte)0xD0, + (byte)0xD1,(byte)0xD2,(byte)0xD3,(byte)0xD4,(byte)0xD5,(byte)0xD6,(byte)0xD7,(byte)0xD8,(byte)0xD9,(byte)0xDA,(byte)0xDB,(byte)0xDC,(byte)0xDD,(byte)0xDE,(byte)0xDF,(byte)0xE0, + (byte)0xE1,(byte)0xE2,(byte)0xE3,(byte)0xE4,(byte)0xE5,(byte)0xE6,(byte)0xE7,(byte)0xE8,(byte)0xE9,(byte)0xEA,(byte)0xEB,(byte)0xEC,(byte)0xED,(byte)0xEE,(byte)0xEF,(byte)0xF0, + (byte)0xF1,(byte)0xF2,(byte)0xF3,(byte)0xF4,(byte)0xF5,(byte)0xF6,(byte)0xF7,(byte)0xF8,(byte)0xF9,(byte)0xFA,(byte)0xFB,(byte)0xFC,(byte)0xFD,(byte)0xFE,(byte)0xFF,(byte)0x00 + }; + + private static byte[] displayString = {(byte)'A',(byte)'P',(byte)'P',(byte)'L',(byte)'E',(byte)'T',(byte)'1'}; + + private static final byte DCS_8_BIT_DATA = 0x04; + /** + * Constructor of the applet + */ + public Api_2_Erh_Post_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Erh_Post_1 thisApplet = new Api_2_Erh_Post_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register on EVENT DOWNLOAD CALL CONTROL BY NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : getTheHandler and than post(true) + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + envRespHdlr.post(true); + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : Append data and post(true) + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short)0x00FA); + envRespHdlr.post(true); + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : use the methode appendTLV after the using of the post(true) methode + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.post(true); + + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + bRes = false; + } + catch (ToolkitException e){ + if(e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) + bRes = true ; + } + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : use the methode post(FALSE) and send a display text + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.post(false); + + //send the proactive command + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5: use the methode post() without appendTLV() and send a display text + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + + envRespHdlr.post(false); + + //send the proactive command + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + + bRes = true; + } + + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // -------------------------------------------- + // Test Case 6 : use the post() methode after a display text command + testCaseNb = (byte) 6 ; + + bRes = false ; + try{ + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x10, (short) 0x0010); + //send the proactive command + proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, displayString, (short) 0, (short) displayString.length); + proHdlr.send(); + + try { + envRespHdlr.post(false); + bRes = false; + } + + catch (ToolkitException e){ + if(e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 6 : + // -------------------------------------------- + // Test Case 7 : try to use the methode post(true) after the using of the methode post(false) + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.post(false); + bRes = false; + try{ + envRespHdlr.post(true); + } + catch (ToolkitException e){ + if(e.getReason()==ToolkitException.HANDLER_NOT_AVAILABLE) + bRes = true ; + } + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 7 : + // -------------------------------------------- + // Test Case 8 : In case of CALL_CONTROL the CAT Runtime Environment set the boolean value always to true + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00, (short) 0x0010); + envRespHdlr.post(false); + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 8 : + // -------------------------------------------- + // Test Case 9 : In case of CALL_CONTROL the CAT Runtime Environment set the boolean value always to true + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + envRespHdlr.appendTLV((byte)0x01,data,(short)0x0010,(short)0x0010); + envRespHdlr.post(true); + bRes = true; + } + catch (Exception e){ + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 9 : + // -------------------------------------------- + // Test Case 10 : Resulting response length greater than 256. + // Conditional test should only be perform if EnvelopeResponseHandler is greater than 256 + testCaseNb = (byte) 10 ; + bRes = false ; + if(envRespHdlr.getCapacity() > (short)0x0100) + { + try { + envRespHdlr.appendTLV((byte)0x01,data,(short) 0x00,(short)0x00FB); + bRes = false; + try{ + envRespHdlr.appendTLV((byte)0x02,data,(short) 0x00,(short)0x0001); + envRespHdlr.post(true); + } + catch (APDUException e){ + if(e.getReason()==APDUException.BAD_LENGTH) + bRes = true ; + } + } + catch (Exception e){ + bRes = false ; + } + } + else bRes = true; + reportTestOutcome(testCaseNb, bRes) ; + break; + + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/Test_Api_2_Erh_Post.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/Test_Api_2_Erh_Post.java new file mode 100644 index 0000000000000000000000000000000000000000..bef669021440a313581634af450cd7e87be8a76a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/Test_Api_2_Erh_Post.java @@ -0,0 +1,179 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Erh_Post.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_erh_post; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_erh_post + * + * @version 0.0.1 - 24 mars 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Erh_Post extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_erh_post"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Erh_Post() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcases */ + /*********************************************************************/ + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test case 1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // Test case 2 + response = test.unrecognizedEnvelope(); + result &= response.checkData("0181FA01 02030405 06070809 0A0B0C0D" + + "0E0F1011 12131415 16171819 1A1B1C1D" + + "1E1F2021 22232425 26272829 2A2B2C2D" + + "2E2F3031 32333435 36373839 3A3B3C3D" + + "3E3F4041 42434445 46474849 4A4B4C4D" + + "4E4F5051 52535455 56575859 5A5B5C5D" + + "5E5F6061 62636465 66676869 6A6B6C6D" + + "6E6F7071 72737475 76777879 7A7B7C7D" + + "7E7F8081 82838485 86878889 8A8B8C8D" + + "8E8F9091 92939495 96979899 9A9B9C9D" + + "9E9FA0A1 A2A3A4A5 A6A7A8A9 AAABACAD" + + "AEAFB0B1 B2B3B4B5 B6B7B8B9 BABBBCBD" + + "BEBFC0C1 C2C3C4C5 C6C7C8C9 CACBCCCD" + + "CECFD0D1 D2D3D4D5 D6D7D8D9 DADBDCDD" + + "DEDFE0E1 E2E3E4E5 E6E7E8E9 EAEBECED" + + "EEEFF0F1 F2F3F4F5 F6F7F8F9 FA"); + + result &= response.checkSw("9000"); + + // Test case 3 + response = test.unrecognizedEnvelope(); + result &= response.checkData("01100102 03040506 0708090A 0B0C0D0E 0F10"); + result &= response.checkSw("9000"); + + // Test case 4 + response = test.unrecognizedEnvelope(); + result &= response.checkData("01100102 03040506 0708090A 0B0C0D0E 0F10"); + result &= response.checkSw("6200"); + response = test.envelopeEventDownloadUserActivity(); // Dummy command to get the 91XX status word + result &= response.checkSw("9115"); + response = test.fetch("15"); + result &= response.checkData("D0138103 01218082 0281028D 08044150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + // Test case 5 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9115"); + response = test.fetch("15"); + result &= response.checkData("D0138103 01218082 0281028D 08044150" + + "504C4554 31"); + test.terminalResponse("81030121 00020282 81030100"); + + // Test case 6 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9115"); + response = test.fetch("15"); + result &= response.checkData("D0138103 01218082 0281028D 08044150" + + "504C4554 31"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9000"); + + // Test case 7 + response = test.unrecognizedEnvelope(); + result &= response.checkData("01100102 03040506 0708090A 0B0C0D0E 0F10"); + result &= response.checkSw("6200"); + + // Test case 8 + response = test.envelopeCallControlByNAA(); + result &= response.checkData("01100102 03040506 0708090A 0B0C0D0E 0F10"); + result &= response.checkSw("9000"); + + // Test case 9 + response = test.envelopeCallControlByNAA(); + result &= response.checkData("01101112 13141516 1718191A 1B1C1D1E 1F20"); + result &= response.checkSw("9000"); + + // Test case 10 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0ACCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..cfb1606e77ed03a754706ffabfb28826e6013d5c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_erh_post.Api_2_Erh_Post_1 +uicc.test.toolkit.api_2_erh_post +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/javacard/api_2_erh_post.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/javacard/api_2_erh_post.cap new file mode 100644 index 0000000000000000000000000000000000000000..621484c1d7ff92cfff3fea055cbfdd24aa87955f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_erh_post/javacard/api_2_erh_post.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/Api_2_Ers_Gthd_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/Api_2_Ers_Gthd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..255d24151cdb29cef52044eb3fe3017c0cc2461a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/Api_2_Ers_Gthd_1.java @@ -0,0 +1,150 @@ +//----------------------------------------------------------------------------- +//Api_2_Ers_Gthd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_ers_gthd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.EnvelopeResponseHandler; +import uicc.toolkit.EnvelopeResponseHandlerSystem; +import uicc.toolkit.ProactiveHandlerSystem; +import uicc.toolkit.ProactiveHandler; +import uicc.toolkit.ToolkitException; +/** + * Test Area : uicc.test.toolkit.api_2_ers_gthd + * + * @version 0.0.1 - 2 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Ers_Gthd_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + + /** + * Constructor of the applet + */ + public Api_2_Ers_Gthd_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Ers_Gthd_1 thisApplet = new Api_2_Ers_Gthd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : use th methode getTheHandler() Twice + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + EnvelopeResponseHandler EnvRespHdlr1 = EnvelopeResponseHandlerSystem.getTheHandler(); + EnvelopeResponseHandler EnvRespHdlr2 = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (EnvRespHdlr1==EnvRespHdlr2 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : verify that the methode getTheHandler return EnvelopeResponseHandler reference + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + EnvelopeResponseHandler EnvRespHdlr1 = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (EnvRespHdlr1 instanceof EnvelopeResponseHandler) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : verify that the methode getTheHandler does not return NULL + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + EnvelopeResponseHandler EnvRespHdlr1 = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (EnvRespHdlr1!=null) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 3 : EnvelopeResponseHandler shall not be available after the sending of a proactive command + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + ProactiveHandlerSystem.getTheHandler().initMoreTime(); + ProactiveHandlerSystem.getTheHandler().send(); + bRes = false; + try { + EnvelopeResponseHandler EnvRespHdlr1 = EnvelopeResponseHandlerSystem.getTheHandler(); + } + catch(ToolkitException e) + { + bRes = (e.getReason() == ToolkitException.HANDLER_NOT_AVAILABLE); + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } +} + + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/Test_Api_2_Ers_Gthd.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/Test_Api_2_Ers_Gthd.java new file mode 100644 index 0000000000000000000000000000000000000000..d4fb91c4419b5f8e5344441a15842f62ada026eb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/Test_Api_2_Ers_Gthd.java @@ -0,0 +1,116 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Ers_Gthd.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_ers_gthd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.api_2_ers_gthd + * + * @version 0.0.1 - 2 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Ers_Gthd extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_ers_gthd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Ers_Gthd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Applet installation */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test cases 1,2,3 + for (byte i = 0; i< 3; i++) + { + response = test.unrecognizedEnvelope(); + } + + // Test case 4 + response = test.unrecognizedEnvelope(); + result = response.checkSw("910B"); + response = test.fetch("0B"); + result &= response.checkData("D0098103 01020082 028182"); + response = test.terminalResponse("81030102 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "04CCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..96df82e7f241d7c4c8ed9d75384d765c5766e94d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_ers_gthd.Api_2_Ers_Gthd_1 +uicc.test.toolkit.api_2_ers_gthd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/javacard/api_2_ers_gthd.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/javacard/api_2_ers_gthd.cap new file mode 100644 index 0000000000000000000000000000000000000000..180fc4a3bc6e5855a83899c88c4b4cf61d709f16 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_ers_gthd/javacard/api_2_ers_gthd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/Api_2_Pah_Apda_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/Api_2_Pah_Apda_1.java new file mode 100644 index 0000000000000000000000000000000000000000..78f5e21619a0d4a5d3050a11caa4d9679c0a345f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/Api_2_Pah_Apda_1.java @@ -0,0 +1,430 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Apda_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_apda; + +import uicc.test.util.*; +import uicc.toolkit.*; +import javacard.framework.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_apda + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Apda_1 extends TestToolkitApplet +{ + private byte[] buffer5 = new byte[5]; + private byte[] buffer256 = new byte[256] ; + private byte[] buffer255 = new byte[255] ; + private byte[] buffer = new byte[8] ; + private byte[] copyBuffer = new byte[32] ; + private byte[] compareBuffer = new byte[32] ; + private byte[] copyBuffer255 = new byte[255] ; + private byte[] compareBuffer255 = new byte[255] ; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Apda_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Apda_1 thisApplet = new Api_2_Pah_Apda_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + short offset = 0 ; + short length = 0 ; + + // -------------------------------------------- + // Test Case 1 : Null buffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + length = (short)1 ; + + proHdlr.appendArray(null, offset, length) ; + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : offset>buffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + offset = (short)6 ; + length = (short)0 ; + + proHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + offset = (short)-1 ; + length = (short)1 ; + + proHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : length>buffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + length = (short)6 ; + + proHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : offset + length>buffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + offset = (short)3 ; + length = (short)3 ; + + proHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : length < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + length = (short)-1 ; + + proHdlr.appendArray(buffer5, offset, length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : handler overflow + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + try { + offset = (short)0 ; + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity() + 1)]; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + proHdlr.appendArray(TempBuffer, offset,(short) TempBuffer.length) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : A successfull append does not modify the current TLV + testCaseNb = (byte) 8 ; + bRes = false ; + + // Initialise buffer + for (short i=0; i<(short)buffer.length; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; + } + + try { + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select Command Details TLV + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append buffer + offset = (short)0 ; + length = (short)buffer.length ; + proHdlr.appendArray(buffer, offset, length) ; + + // Verify current TLV + result = proHdlr.getValueLength() ; + + bRes = (result == (short)3) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Successfull call + testCaseNb = (byte) 9 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer.length; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + compareBuffer[i] = (byte)((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + } + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + offset = (short)0 ; + length = (short)buffer.length ; + proHdlr.appendArray(buffer, offset, length) ; + + // Copy the handler + offset = (short) 0 ; + length = (short) 8 ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer.length; i++) { + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + + if (i>=(byte)2) { + compareBuffer[(short)(i+6)] = (byte)i ; // FF FE FD FC FB FA F9 F8 02 03 04 05 06 07 + } + } + + try { + + // Append buffer + offset = (short)2 ; + length = (short)6 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)14 ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + testCaseNb = (byte) 11 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer.length; i++) { + buffer[i] = (byte) ((i+1)*0x11) ; // 11 22 33 44 55 66 77 88 + + if (i>=(byte)2) { + compareBuffer[(short)(i+12)] = (byte)((i+1)*0x11) ; // FF FE FD FC FB FA F9 F8 02 03 04 05 06 07 33 44 55 66 + } + } + + try { + + // Append buffer + offset = (short)2 ; + length = (short)4 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)18 ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + bRes2 = false ; + + // Initialise buffers + for (short i=0; i<(short)buffer255.length; i++) { + buffer255[i] = (byte)i ; + compareBuffer255[i] = (byte)i ; + } + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + offset = (short)0 ; + length = (short)253 ; + proHdlr.appendArray(buffer255, offset, length) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + + // Copy the handler + offset = (short) 0 ; + length = (short) proHdlr.getLength() ; + proHdlr.copy(copyBuffer255, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer255, offset, + compareBuffer255, offset, length) ; + + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/Test_Api_2_Pah_Apda.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/Test_Api_2_Pah_Apda.java new file mode 100644 index 0000000000000000000000000000000000000000..9ae8683823a4bf17bcf9b342ecd56cbb9859a4e8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/Test_Api_2_Pah_Apda.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Apda.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_apda; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_apda + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Apda extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_apda"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Apda() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 12 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4948ba80a0109368b4da1436ae8e318cef60a47c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_apda.Api_2_Pah_Apda_1 +uicc.test.toolkit.api_2_pah_apda +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/javacard/api_2_pah_apda.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/javacard/api_2_pah_apda.cap new file mode 100644 index 0000000000000000000000000000000000000000..f26dc88aaef0e414139e655b0ede2bb760430905 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_apda/javacard/api_2_pah_apda.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/Api_2_Pah_Aptlb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/Api_2_Pah_Aptlb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..c0bd1b473b70d8955ff63a7b28924fc2dd3aa091 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/Api_2_Pah_Aptlb_Bss_1.java @@ -0,0 +1,512 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlb_bss; + +import javacard.framework.*; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlb_bss + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlb_Bss_1 extends TestToolkitApplet +{ + private byte compareBuffer[] = new byte[256] ; + private byte buffer5[] = new byte[5] ; + private byte buffer256[] = new byte[256] ; + private byte buffer[] = new byte[32] ; + private byte copyBuffer[] = new byte[256] ; + + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlb_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlb_Bss_1 thisApplet = new Api_2_Pah_Aptlb_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short length = 0 ; + short offset = 0 ; + short valueLength = 0 ; + short valueOffset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null value + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)1 ; + + try { + proHdlr.appendTLV(tag, null, valueOffset, valueLength) ; + } catch (NullPointerException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : valueOffset > value.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)6 ; + valueLength = (short)0 ; + + try { + proHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : valueOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)-1 ; + valueLength = (short)1 ; + + try { + proHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : valueLength > value.Length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)6 ; + + try { + proHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : valueOffset + valueLength > value.Length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)3 ; + valueLength = (short)3 ; + + try { + proHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : valueLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)-1 ; + + try { + proHdlr.appendTLV(tag, buffer5, valueOffset, valueLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : handler overflow + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity() - 1)]; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + try { + proHdlr.appendTLV(tag, TempBuffer, valueOffset, (short)TempBuffer.length); + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : bad input parameter + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + tag = (byte)1 ; + valueOffset = (short)0 ; + valueLength = (short)256 ; + + try { + proHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : the current TLV is not modified + testCaseNb = (byte) 9 ; + bRes = false ; + + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + } + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + tag = (byte)0x04 ; + valueOffset = (short)0 ; + valueLength = (short)8 ; + proHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Verify current TLV + result = proHdlr.getValueLength() ; + bRes = (result == (short)3) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + testCaseNb = (byte) 10 ; + bRes = false ; + + tag = (byte)4 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + compareBuffer[(short)(i+2)] = (byte)((byte)0xFF-i) ; // 04 08 FF FE FD FC FB FA F9 F8 + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)8 ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + valueOffset = (short)0 ; + valueLength = (short)8 ; + proHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Copy the handler + offset = (short) 0 ; + length = (short) proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + testCaseNb = (byte) 11 ; + bRes = false ; + + tag = (byte)0x85 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + } + compareBuffer[10] = tag ; + compareBuffer[11] = (byte)0x06 ; + for (short i=0; i<(short)6; i++) { + compareBuffer[(short)(12+i)] = (byte)(i+2) ; // 04 08 FF FE FD FC FB FA F9 F8 85 06 02 03 04 05 06 07 + } + + + try { + + // Append buffer + valueOffset = (short)2 ; + valueLength = (short)6 ; + proHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + tag = (byte) 0x01 ; + // Initialise buffers + for (short i=0; i<8; i++) { + buffer[i] = (byte) ((i+1)*0x11) ; // 11 22 33 44 55 66 77 88 + } + + compareBuffer[18] = tag ; + compareBuffer[19] = (byte) 0x04 ; + compareBuffer[20] = (byte) 0x33 ; + compareBuffer[21] = (byte) 0x44 ; + compareBuffer[22] = (byte) 0x55 ; + compareBuffer[23] = (byte) 0x66 ; + + try { + + // Append buffer + valueOffset = (short)2 ; + valueLength = (short)4 ; + proHdlr.appendTLV(tag, buffer, valueOffset, valueLength) ; + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successfull call + testCaseNb = (byte) 13 ; + bRes = false ; + + tag = (byte)04 ; + + // Initialise buffers + for (short i=0; i<(short)81; i++) { + buffer256[i] = (byte)i ; + compareBuffer[(short)(i+3)] = (byte)i ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0x80 ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + valueOffset = (short)0 ; + valueLength = (short)0x80 ; + proHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + + // Copy the handler + offset = (short) 0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successfull call (limit case) + testCaseNb = (byte) 14 ; + bRes = false ; + bRes2 = false ; + + tag = (byte)04 ; + + // Initialise buffers + for (short i=0; i<(short)0xFA; i++) { + buffer256[i] = (byte)i ; + compareBuffer[(short)(i+3)] = (byte)i ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xFA ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + valueOffset = (short)0 ; + valueLength = (short)250 ; + proHdlr.appendTLV(tag, buffer256, valueOffset, valueLength) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + + // Copy the handler + offset = (short) 0 ; + length = (short) proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/Test_Api_2_Pah_Aptlb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/Test_Api_2_Pah_Aptlb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..4f1b1de2c3d38bc55f56d04c75ef70a92e72ecab --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/Test_Api_2_Pah_Aptlb_Bss.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Aptlb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlb_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlb_bss + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlb_Bss extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlb_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 14 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9843892d979048f53ddbe0f620577fd560c06186 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlb_bss.Api_2_Pah_Aptlb_Bss_1 +uicc.test.toolkit.api_2_pah_aptlb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/javacard/api_2_pah_aptlb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/javacard/api_2_pah_aptlb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..1750177d84b38255d08233ee5a65eb88c4310dc3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss/javacard/api_2_pah_aptlb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/Api_2_Pah_Aptlb_Bss_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/Api_2_Pah_Aptlb_Bss_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..de09c11c89eaec4710256db0239cf795f6a50688 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/Api_2_Pah_Aptlb_Bss_Bss_1.java @@ -0,0 +1,553 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlb_Bss_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlb_bss_bss; + +import javacard.framework.Util; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlb_bss_bss + * + * @version 0.0.1 - 21 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlb_Bss_Bss_1 extends TestToolkitApplet +{ + private byte buffer5[] = new byte[5]; + private byte buffer256[] = new byte[256]; + private byte buffer[] = new byte[32]; + private byte copyBuffer[] = new byte[256]; + private byte compareBuffer[] = new byte[256]; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlb_Bss_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlb_Bss_Bss_1 thisApplet = new Api_2_Pah_Aptlb_Bss_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + + short value1Length = 0 ; + short value1Offset = 0 ; + short value2Length = 5 ; + short value2Offset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null value1 + testCaseNb = (byte) 1 ; + bRes = false ; + tag = (byte)1 ; + value1Offset = (short)0; + value1Length = (short)5; + value2Offset = (short)0 ; + value2Length = (short)5 ; + + try { + proHdlr.appendTLV(tag, null,value1Offset,value1Length,buffer5, value2Offset, value2Length) ; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : Null value2 + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + proHdlr.appendTLV(tag,buffer5,value1Offset,value1Length,null,value2Offset, value2Length) ; + } + catch (NullPointerException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : value1Offset >= value1.length + testCaseNb = (byte) 3 ; + bRes = false ; + + tag = (byte)1 ; + value1Offset = (short)5 ; + value1Length = (short)1 ; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : value1Offset < 0 + testCaseNb = (byte) 4 ; + bRes = false ; + + tag = (byte)1 ; + value1Offset = (short)(-1) ; + value1Length = (short)1 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : value1length > value1.length + testCaseNb = (byte) 5 ; + bRes = false ; + + tag = (byte)1 ; + value1Offset = (short)0 ; + value1Length = (short)6 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // ---------------------------------------------------------- + // Test Case 6 : value1Length + value1Offset > value1.length + testCaseNb = (byte) 6 ; + bRes = false ; + + tag = (byte)1 ; + value1Offset = (short)3 ; + value1Length = (short)3 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // ------------------------------- + // Test Case 7 : value1Length < 0 + testCaseNb = (byte) 7 ; + bRes = false ; + + tag = (byte)1 ; + value1Offset = (short)0 ; + value1Length = (short)(-1) ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : value2Offset >= value2.length + testCaseNb = (byte) 8 ; + bRes = false ; + + tag = (byte)1 ; + value1Offset = (short)0 ; + value1Length = (short)1 ; + value2Offset = (short)5 ; + value2Length = (short)1 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 9 : value2Offset < 0 + testCaseNb = (byte) 9 ; + bRes = false ; + + value2Offset = (short)(-1) ; + value2Length = (short)1 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 10 : value2Length > value2.length + testCaseNb = (byte) 10 ; + bRes = false ; + + value2Offset = (short)0 ; + value2Length = (short)6 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 11 : value2Offset + value2Length > value2.length + testCaseNb = (byte) 11 ; + bRes = false ; + + value2Offset = (short)3 ; + value2Length = (short)3 ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------- + // Test Case 12 : value2Length < 0 + testCaseNb = (byte) 12 ; + bRes = false ; + + value2Offset = (short)0 ; + value2Length = (short)(-1) ; + + try { + proHdlr.appendTLV(tag,buffer5, value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------- + // Test Case 13 : Handler overflow + testCaseNb = (byte) 13 ; + bRes = false ; + + value1Offset = (short)0; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity()-1)]; + value1Length = (short)TempBuffer.length; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + proHdlr.appendTLV(tag,TempBuffer,value1Offset,value1Length,buffer5,value2Offset,value2Length) ; + } + catch (ToolkitException e) { + if(e.getReason() == ToolkitException.HANDLER_OVERFLOW) + bRes = true; + else + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 14 : Bad Parameter exception + testCaseNb = (byte) 14 ; + bRes = false ; + + value1Offset = (short)0; + value1Length = (short)256 ; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + proHdlr.appendTLV(tag,buffer256,value1Offset,value1Length,buffer256,value2Offset,value2Length) ; + } + catch (ToolkitException e) { + if(e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) + bRes = true; + else + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 15 : Bad Parameter exception + testCaseNb = (byte) 15 ; + bRes = false ; + + value1Offset = (short)0; + value1Length = (short)1 ; + value2Offset = (short)0 ; + value2Length = (short)256 ; + + try { + proHdlr.appendTLV(tag,buffer256,value1Offset,value1Length,buffer256,value2Offset,value2Length) ; + } + catch (ToolkitException e) { + if(e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) + bRes = true; + else + bRes = false; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 16 : successful call does not modify the current TLV + testCaseNb = (byte) 16 ; + bRes = false ; + + buffer5[0] = (byte)0x11; + buffer5[1] = (byte)0x22; + buffer5[2] = (byte)0x33; + buffer5[3] = (byte)0x99; + buffer5[4] = (byte)0x77; + + for(byte i = 0; i <= 0x0F ; i++) + buffer[i] = (byte)(0xFF-i); + + try { + proHdlr.clear(); + proHdlr.appendTLV((byte)0x81,buffer5,(short)0,(short)3); + proHdlr.appendTLV((byte)0x82,buffer5,(short)3,(short)2); + proHdlr.findTLV((byte)0x81,(byte)1); // Select the first TLV + + value1Offset = (short)0; + value1Length = (short)8; + value2Offset = (short)8; + value2Length = (short)8; + proHdlr.appendTLV((byte)0x04,buffer,value1Offset,value1Length,buffer,value2Offset,value2Length); + bRes = (proHdlr.getValueLength() == (short)3); // Check the current TLV + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 17 : successful call + testCaseNb = (byte) 17 ; + bRes = false ; + // Init compareBuffer + compareBuffer = new byte[0x12]; + Util.arrayCopyNonAtomic(buffer,(short)0,compareBuffer,(short)2,(short)0x10); + compareBuffer[0] = (byte)0x04; + compareBuffer[1] = (byte)0x10; + + copyBuffer = new byte[0x12]; + + try { + proHdlr.clear(); + proHdlr.appendTLV((byte)0x04,buffer,value1Offset,value1Length,buffer,value2Offset,value2Length); + proHdlr.copy(copyBuffer,(short)0,(short)copyBuffer.length); + bRes = (Util.arrayCompare(copyBuffer,(short)0,compareBuffer,(short)0,(short)compareBuffer.length)== 0); + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 18 : successful call + testCaseNb = (byte) 18 ; + bRes = false ; + + buffer = new byte[0x10]; + for(byte i = 0; i < (byte)buffer.length ; i++) + buffer[i] = i; + + // Init compareBuffer + compareBuffer = new byte[0x20]; + short offset = Util.arrayCopyNonAtomic(copyBuffer,(short)0,compareBuffer,(short)0,(short)copyBuffer.length); + compareBuffer[offset++] = (byte)0x85; + compareBuffer[offset++] = (byte)0x0C; + offset = Util.arrayCopyNonAtomic(buffer,(short)0x02,compareBuffer,offset++,(short)6); + Util.arrayCopyNonAtomic(buffer,(short)0x0A,compareBuffer,offset,(short)6); + + // Init copyBuffer + copyBuffer = new byte[0x20]; + try { + value1Offset = (byte)0x02; + value1Length = (byte)0x06; + value2Offset = (byte)0x0A; + value2Length = (byte)0x06; + proHdlr.appendTLV((byte)0x85,buffer,value1Offset,value1Length,buffer,value2Offset,value2Length); + proHdlr.copy(copyBuffer,(short)0,(short)copyBuffer.length); + bRes = (Util.arrayCompare(copyBuffer,(short)0,compareBuffer,(short)0,(short)compareBuffer.length)== 0); + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 19 : successful call + testCaseNb = (byte) 19 ; + bRes = false ; + + for(byte i = 1; i <= (byte)(buffer.length -1); i++) + buffer[(byte)(i-1)] = (byte)(i * 0x11); + buffer[0x0F] = (byte)0; + + // Init compareBuffer + compareBuffer = new byte[0x2A]; + offset = Util.arrayCopyNonAtomic(copyBuffer,(short)0,compareBuffer,(short)0,(short)copyBuffer.length); + compareBuffer[offset++] = (byte)0x01; + compareBuffer[offset++] = (byte)0x08; + offset = Util.arrayCopyNonAtomic(buffer,(short)0x02,compareBuffer,offset++,(short)4); + Util.arrayCopyNonAtomic(buffer,(short)0x0A,compareBuffer,offset,(short)4); + + // Init copyBuffer + copyBuffer = new byte[0x2A]; + try { + value1Offset = (byte)0x02; + value1Length = (byte)0x04; + value2Offset = (byte)0x0A; + value2Length = (byte)0x04; + proHdlr.appendTLV((byte)0x01,buffer,value1Offset,value1Length,buffer,value2Offset,value2Length); + proHdlr.copy(copyBuffer,(short)0,(short)copyBuffer.length); + bRes = (Util.arrayCompare(copyBuffer,(short)0,compareBuffer,(short)0,(short)compareBuffer.length)== 0); + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------- + // Test Case 20 : successful call + testCaseNb = (byte) 20 ; + bRes = false ; + + buffer = new byte[0xFA]; + for(short i = 0; i < (short)buffer.length ; i++) + buffer[i] = (byte)i; + + // Init compareBuffer + compareBuffer = new byte[0xFD]; + compareBuffer[0] = (byte)0x04; + compareBuffer[1] = (byte)0x81; + compareBuffer[2] = (byte)0xFA; + Util.arrayCopyNonAtomic(buffer,(short)0,compareBuffer,(short)3,(short)buffer.length); + + // Init copyBuffer + copyBuffer = new byte[0xFD]; + try { + proHdlr.clear(); + value1Offset = (short)0; + value1Length = (short)0x0080; + value2Offset = (short)0x0080; + value2Length = (short)0x007A; + proHdlr.appendTLV((byte)0x04,buffer,value1Offset,value1Length,buffer,value2Offset,value2Length); + proHdlr.copy(copyBuffer,(short)0,(short)copyBuffer.length); + bRes = (Util.arrayCompare(copyBuffer,(short)0,compareBuffer,(short)0,(short)compareBuffer.length)== 0); + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/Test_Api_2_Pah_Aptlb_Bss_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/Test_Api_2_Pah_Aptlb_Bss_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..3babbbeeeeb835e86a0dfc241b80138f0c764cf1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/Test_Api_2_Pah_Aptlb_Bss_Bss.java @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Aptlb_Bss_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlb_bss_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlb_bss_bss + * + * @version 0.0.1 - 21 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlb_Bss_Bss extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlb_bss_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlb_Bss_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 20 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "14CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5f3abaccf4fe6d439c3f021fcfe6d982063cc0ac --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlb_bss_bss.Api_2_Pah_Aptlb_Bss_Bss_1 +uicc.test.toolkit.api_2_pah_aptlb_bss_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/javacard/api_2_pah_aptlb_bss_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/javacard/api_2_pah_aptlb_bss_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..f94e4b549696e43174122ba1dfbbcdb1038d33c0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlb_bss_bss/javacard/api_2_pah_aptlb_bss_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/Api_2_Pah_Aptlbb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/Api_2_Pah_Aptlbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..eddfc2319ca82ad6d57193460c15a8b39633625e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/Api_2_Pah_Aptlbb_1.java @@ -0,0 +1,252 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlbb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbb; + +import uicc.test.util.*; +import uicc.toolkit.*; +import javacard.framework.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbb + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlbb_1 extends TestToolkitApplet +{ + private byte compareBuffer[] = new byte[256] ; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlbb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlbb_1 thisApplet = new Api_2_Pah_Aptlbb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + byte value = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity() - 1)]; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + proHdlr.appendArray(TempBuffer, offset, (short)TempBuffer.length) ; + + // appendTLV + try { + proHdlr.appendTLV(tag, value) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + proHdlr.appendTLV(tag, value) ; + + // Verify current TLV + result = proHdlr.getValueLength() ; + bRes = (result == (short)3) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value = (byte)0x00 ; + proHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 1; + compareBuffer[2] = value ; + + // Copy the handler + offset = (short)0 ; + length = (short)3 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = javacard.framework.Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Append TLV + tag = (byte)0x01 ; + value = (byte)0xFE ; + proHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[3] = tag ; + compareBuffer[4] = (byte) 1; + compareBuffer[5] = value ; + + // Copy the handler + offset = (short)0 ; + length = (short)6 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = javacard.framework.Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 5 : successful call + testCaseNb = (byte) 5 ; + bRes = false ; + bRes2 = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Initialise buffers + for (short i=0; i<251; i++) { + buffer[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + buffer[1] = (byte)0x81 ; + buffer[2] = (byte)0xF7 ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xF7 ; + tag = (byte)0x84 ; + value = (byte)0x00 ; + compareBuffer[250] = tag ; + compareBuffer[251] = (byte) 1; + compareBuffer[252] = value ; + + // Initialise the handler + offset = (short)0 ; + length = (short)250 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Append TLV + proHdlr.appendTLV(tag, value) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = javacard.framework.Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/Test_Api_2_Pah_Aptlbb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/Test_Api_2_Pah_Aptlbb.java new file mode 100644 index 0000000000000000000000000000000000000000..e60c3344598b6cc72fd8a94fddaf3b2b8690df2a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/Test_Api_2_Pah_Aptlbb.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Aptlbb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbb; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbb + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlbb extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlbb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlbb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7405a8f4cb7cd459b6858674e155f30686663b57 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlbb.Api_2_Pah_Aptlbb_1 +uicc.test.toolkit.api_2_pah_aptlbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/javacard/api_2_pah_aptlbb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/javacard/api_2_pah_aptlbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..da8a71de34204a72fd828910dadb8201c51dcdb3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb/javacard/api_2_pah_aptlbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/Api_2_Pah_Aptlbb_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/Api_2_Pah_Aptlbb_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ef45cec6cf60a387a857e852cc9406cbb10626e5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/Api_2_Pah_Aptlbb_Bss_1.java @@ -0,0 +1,525 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlbb_Bss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbb_bss; + +import javacard.framework.Util; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbb_bss + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlbb_Bss_1 extends TestToolkitApplet +{ + private byte compareBuffer[] = new byte[256] ; + private byte buffer5[] = new byte[5] ; + private byte buffer256[] = new byte[256] ; + private byte buffer[] = new byte[32] ; + private byte copyBuffer[] = new byte[256] ; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlbb_Bss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlbb_Bss_1 thisApplet = new Api_2_Pah_Aptlbb_Bss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short length = 0 ; + short offset = 0 ; + byte value1 = 0 ; + short value2Length = 0 ; + short value2Offset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null value + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)1 ; + + try { + proHdlr.appendTLV(tag, value1, null, value2Offset, value2Length) ; + } catch (NullPointerException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : value2Offset > value2.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)6 ; + value2Length = (short)0 ; + + try { + proHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : value2Offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)-1 ; + value2Length = (short)1 ; + + try { + proHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : value2Length > value2.Length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)6 ; + + try { + proHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : value2Offset + value2Length > value2.Length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)3 ; + value2Length = (short)3 ; + + try { + proHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : valueLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)-1 ; + + try { + proHdlr.appendTLV(tag, value1, buffer5, value2Offset, value2Length) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : handler overflow + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)254 ; + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity() - 1)]; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + proHdlr.appendArray(TempBuffer,(short)0,(short)TempBuffer.length); + try { + proHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : bad input parameter + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + tag = (byte)1 ; + value2Offset = (short)0 ; + value2Length = (short)256 ; + + try { + proHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : the current TLV is not modified + testCaseNb = (byte) 9 ; + bRes = false ; + + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + } + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + tag = (byte)0x04 ; + value1 = (byte)0x05 ; + value2Offset = (short)0 ; + value2Length = (short)8 ; + proHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Verify current TLV + result = proHdlr.getValueLength() ; + bRes = (result == (short)3) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + testCaseNb = (byte) 10 ; + bRes = false ; + + tag = (byte)4 ; + value1 = (byte)0x05 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte) ((byte)0xFF-i) ; // FF FE FD FC FB FA F9 F8 + compareBuffer[(short)(i+3)] = (byte)((byte)0xFF-i) ; // 04 08 FF FE FD FC FB FA F9 F8 + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)9 ; + compareBuffer[2] = value1 ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + value2Offset = (short)0 ; + value2Length = (short)8 ; + proHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Copy the handler + offset = (short) 0 ; + length = (short) proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + testCaseNb = (byte) 11 ; + bRes = false ; + + tag = (byte)0x85 ; + value1 = (byte)0x55 ; + + // Initialise buffers + for (short i=0; i<(short)8; i++) { + buffer[i] = (byte)i ; // 00 01 02 03 04 05 06 07 + } + compareBuffer[11] = tag ; + compareBuffer[12] = (byte)0x07 ; + compareBuffer[13] = value1 ; + + for (short i=0; i<(short)6; i++) { + compareBuffer[(short)(14+i)] = (byte)(i+2) ; // 04 08 FF FE FD FC FB FA F9 F8 85 06 02 03 04 05 06 07 + } + + + try { + + // Append buffer + value2Offset = (short)2 ; + value2Length = (short)6 ; + proHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + tag = (byte) 0x01 ; + value1 = (byte) 0x44 ; + // Initialise buffers + for (short i=0; i<8; i++) { + buffer[i] = (byte) ((i+1)*0x11) ; // 11 22 33 44 55 66 77 88 + } + + compareBuffer[20] = tag ; + compareBuffer[21] = (byte) 0x05 ; + compareBuffer[22] = value1 ; + compareBuffer[23] = (byte) 0x33 ; + compareBuffer[24] = (byte) 0x44 ; + compareBuffer[25] = (byte) 0x55 ; + compareBuffer[26] = (byte) 0x66 ; + + try { + + // Append buffer + value2Offset = (short)2 ; + value2Length = (short)4 ; + proHdlr.appendTLV(tag, value1, buffer, value2Offset, value2Length) ; + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successfull call + testCaseNb = (byte) 13 ; + bRes = false ; + + tag = (byte)04 ; + value1 = (byte) 0x00 ; + + // Initialise buffers + for (short i=0; i<(short)80; i++) { + buffer256[i] = (byte)(i+1) ; + compareBuffer[(short)(i+4)] = (byte)(i+1) ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0x80 ; + compareBuffer[3] = value1 ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + value2Offset = (short)0 ; + value2Length = (short)0x7F ; + proHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + + // Copy the handler + offset = (short) 0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successfull call (limit case) + testCaseNb = (byte) 14 ; + bRes = false ; + bRes2 = false ; + + tag = (byte)04 ; + value1 = (byte) 0x00 ; + + // Initialise buffers + for (short i=0; i<(short)0xFA; i++) { + buffer256[i] = (byte)(i+1) ; + compareBuffer[(short)(i+4)] = (byte)(i+1) ; + } + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xFA ; + compareBuffer[3] = value1 ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append buffer + value2Offset = (short)0 ; + value2Length = (short)249 ; + proHdlr.appendTLV(tag, value1, buffer256, value2Offset, value2Length) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + // Copy the handler + offset = (short) 0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(copyBuffer, offset, length) ; + + // Compare buffer + result = javacard.framework.Util.arrayCompare(copyBuffer, offset, + compareBuffer, offset, length) ; + + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/Test_Api_2_Pah_Aptlbb_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/Test_Api_2_Pah_Aptlbb_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..65d5c9aa9984368c49a4c6ea4341839136130bf6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/Test_Api_2_Pah_Aptlbb_Bss.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Aptlbb_Bss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbb_bss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbb_bss + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlbb_Bss extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlbb_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlbb_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 14 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..882ed0b59964941b8efd9340f1d6a432e9e9e562 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlbb_bss.Api_2_Pah_Aptlbb_Bss_1 +uicc.test.toolkit.api_2_pah_aptlbb_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/javacard/api_2_pah_aptlbb_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/javacard/api_2_pah_aptlbb_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..70ca98924f69e7abec3350c91fc0cef3b7e28e50 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbb_bss/javacard/api_2_pah_aptlbb_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/Api_2_Pah_Aptlbbb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/Api_2_Pah_Aptlbbb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..8a9cb2f8316e6794d178bb8c210edc2102bab7e9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/Api_2_Pah_Aptlbbb_1.java @@ -0,0 +1,249 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlbbb_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbbb; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import javacard.framework.*; +import uicc.test.util.*; +import uicc.toolkit.*; + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbbb + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlbbb_1 extends TestToolkitApplet +{ + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlbbb_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlbbb_1 thisApplet = new Api_2_Pah_Aptlbbb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + byte value1 = 0 ; + byte value2 = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + byte[] compareBuffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + byte[] TmpBuffer = new byte[(short)(proHdlr.getCapacity()-1)]; + Util.arrayFillNonAtomic(TmpBuffer,(short)0,(short)TmpBuffer.length,(byte)0); + proHdlr.appendArray(TmpBuffer,offset,(short)TmpBuffer.length) ; + + // appendTLV + try { + proHdlr.appendTLV(tag, value1, value2) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1); + byte command_details_value = proHdlr.getValueByte((short)0); + + // Append TLV + proHdlr.appendTLV(tag, value1, value2) ; + + // Verify current TLV + bRes = (proHdlr.getValueByte((short)0) == command_details_value) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value1 = (byte)0x00 ; + value2 = (byte)0x01 ; + proHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte)2; + compareBuffer[2] = value1; + compareBuffer[3] = value2; + + // Copy the handler + offset = (short)0 ; + length = (short)4 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4; + bRes = false ; + + try { + + // Append TLV + tag = (byte)0x01 ; + value1 = (byte)0xFE ; + value2 = (byte)0xFD ; + proHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[4] = tag ; + compareBuffer[5] = (byte)2; + compareBuffer[6] = value1 ; + compareBuffer[7] = value2; + + // Copy the handler + offset = (short)0 ; + length = (short)8 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : successful call + testCaseNb = (byte) 5 ; + bRes = false ; + bRes2 = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Initialise buffers + for (short i=0; i<250; i++) { + buffer[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + buffer[1] = (byte)0x81 ; + buffer[2] = (byte)0xF6 ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xF6 ; + tag = (byte)0x84 ; + value1 = (byte)0x00 ; + value2 = (byte)0x01 ; + compareBuffer[249] = tag ; + compareBuffer[250] = (byte)2 ; + compareBuffer[251] = value1 ; + compareBuffer[252] = value2 ; + + // Initialise the handler + offset = (short)0 ; + length = (short)249 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Append TLV + proHdlr.appendTLV(tag, value1, value2) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = javacard.framework.Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/Test_Api_2_Pah_Aptlbbb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/Test_Api_2_Pah_Aptlbbb.java new file mode 100644 index 0000000000000000000000000000000000000000..220cce7a2d2cb73460e5a541d09dbb37c1804005 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/Test_Api_2_Pah_Aptlbbb.java @@ -0,0 +1,100 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Aptlbbb.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbbb; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbbb + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlbbb extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlbbb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlbbb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..2500ed3cc8ed01c598c2de8ea624a825d87bc989 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlbbb.Api_2_Pah_Aptlbbb_1 +uicc.test.toolkit.api_2_pah_aptlbbb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/javacard/api_2_pah_aptlbbb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/javacard/api_2_pah_aptlbbb.cap new file mode 100644 index 0000000000000000000000000000000000000000..d97bcf4886fbc2fe4005d410ffcfd315b5cd0266 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbb/javacard/api_2_pah_aptlbbb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/Api_2_Pah_Aptlbbs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/Api_2_Pah_Aptlbbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..74604b43630e458f909972fdfdc0e2272ab1a133 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/Api_2_Pah_Aptlbbs_1.java @@ -0,0 +1,253 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlbbs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbbs; + +import javacard.framework.*; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbbs + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlbbs_1 extends TestToolkitApplet +{ + private byte compareBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlbbs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlbbs_1 thisApplet = new Api_2_Pah_Aptlbbs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + byte value1 = 0 ; + short value2 = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + byte[] TmpBuffer = new byte[(short)(proHdlr.getCapacity()-1)]; + Util.arrayFillNonAtomic(TmpBuffer,(short)0,(short)TmpBuffer.length,(byte)0); + proHdlr.appendArray(TmpBuffer,offset,(short)TmpBuffer.length) ; + + // appendTLV + try { + proHdlr.appendTLV(tag, value1, value2) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1); + byte command_details_value = proHdlr.getValueByte((short)0); + + // Append TLV + proHdlr.appendTLV(tag, value1, value2) ; + + // Verify current TLV + bRes = (proHdlr.getValueByte((short)0) == command_details_value) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value1 = (byte)0x00 ; + value2 = (short)0x0102 ; + proHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 3; + compareBuffer[2] = value1 ; + compareBuffer[3] = (byte)(value2>>8 & (short)0x00FF); + compareBuffer[4] = (byte)(value2 & (short)0x00FF) ; + + // Copy the handler + offset = (short)0 ; + length = (short)5 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4; + bRes = false ; + + try { + + // Append TLV + tag = (byte)0x01 ; + value1 = (byte)0xFE ; + value2 = (short)0xFDFC ; + proHdlr.appendTLV(tag, value1, value2) ; + + // Initialise compareBuffer + compareBuffer[5] = tag ; + compareBuffer[6] = (byte) 3; + compareBuffer[7] = value1 ; + compareBuffer[8] = (byte)(value2>>8 & (short)0x00FF); + compareBuffer[9] = (byte)(value2 & (short)0x00FF); + + // Copy the handler + offset = (short)0 ; + length = (short)10 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : successful call + testCaseNb = (byte) 5 ; + bRes = false ; + bRes2 = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Initialise buffers + for (short i=0; i<250; i++) { + buffer[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + buffer[1] = (byte)0x81 ; + buffer[2] = (byte)0xF5 ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xF5 ; + tag = (byte)0x84 ; + value1 = (byte)0x00 ; + value2 = (short)0x0102 ; + compareBuffer[248] = tag ; + compareBuffer[249] = (byte)3 ; + compareBuffer[250] = value1 ; + compareBuffer[251] = (byte)(value2>>8 & (short)0x00FF); + compareBuffer[252] = (byte)(value2 & (short)0x00FF); + + // Initialise the handler + offset = (short)0 ; + length = (short)248 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Append TLV + proHdlr.appendTLV(tag, value1, value2) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/Test_Api_2_Pah_Aptlbbs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/Test_Api_2_Pah_Aptlbbs.java new file mode 100644 index 0000000000000000000000000000000000000000..20b8af437e80a25d2c02d65747db83485b8d2b61 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/Test_Api_2_Pah_Aptlbbs.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Aptlbbs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbbs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbbs + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlbbs extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlbbs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlbbs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b6bd95a98372345be0bd01a07c7e3a655afaff71 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlbbs.Api_2_Pah_Aptlbbs_1 +uicc.test.toolkit.api_2_pah_aptlbbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/javacard/api_2_pah_aptlbbs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/javacard/api_2_pah_aptlbbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..e46904557d8e65c29e91907aee9a6dc6d0444f0d Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbbs/javacard/api_2_pah_aptlbbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/Api_2_Pah_Aptlbs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/Api_2_Pah_Aptlbs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..689c1d9844a85564e582997ed6aad5e77deb301b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/Api_2_Pah_Aptlbs_1.java @@ -0,0 +1,249 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlbs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbs; + +import javacard.framework.*; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbs + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlbs_1 extends TestToolkitApplet +{ + private byte compareBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlbs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlbs_1 thisApplet = new Api_2_Pah_Aptlbs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short value = 0 ; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity()-1)]; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + proHdlr.appendArray(buffer, offset, (short)TempBuffer.length); + + // appendTLV + try { + proHdlr.appendTLV(tag, value) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + proHdlr.appendTLV(tag, value) ; + + // Verify current TLV + result = proHdlr.getValueLength() ; + bRes = (result == (short)3) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value = (short)0x0001 ; + proHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 2; + compareBuffer[2] = (byte)(value>>8 & (short)0x00FF) ; + compareBuffer[3] = (byte)(value & (short)0x00FF) ; + + // Copy the handler + offset = (short)0 ; + length = (short)4 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Append TLV + tag = (byte)0x01 ; + value = (short)0xFEFF ; + proHdlr.appendTLV(tag, value) ; + + // Initialise compareBuffer + compareBuffer[4] = tag ; + compareBuffer[5] = (byte) 2; + compareBuffer[6] = (byte)(value>>8 & (short)0x00FF); + compareBuffer[7] = (byte)(value & (short)0x00FF); + + // Copy the handler + offset = (short)0 ; + length = (short)8 ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 5 : successful call + testCaseNb = (byte) 5 ; + bRes = false ; + bRes2 = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Initialise buffers + for (short i=0; i<251; i++) { + buffer[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + buffer[1] = (byte)0x81 ; + buffer[2] = (byte)0xF7 ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xF7 ; + tag = (byte)0x84 ; + value = (short)0x0001 ; + compareBuffer[249] = tag ; + compareBuffer[250] = (byte) 2; + compareBuffer[251] = (byte)(value>>8 & (short)0x00FF); + compareBuffer[252] = (byte)(value & (short)0x00FF); + + // Initialise the handler + offset = (short)0 ; + length = (short)249 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Append TLV + proHdlr.appendTLV(tag, value) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/Test_Api_2_Pah_Aptlbs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/Test_Api_2_Pah_Aptlbs.java new file mode 100644 index 0000000000000000000000000000000000000000..9af043c98ef76a67268ac5723814d0079ad573a3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/Test_Api_2_Pah_Aptlbs.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Aptlbs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbs + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlbs extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlbs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlbs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4b8a0b3f40575b729cf59a595df9a234da867a93 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlbs.Api_2_Pah_Aptlbs_1 +uicc.test.toolkit.api_2_pah_aptlbs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/javacard/api_2_pah_aptlbs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/javacard/api_2_pah_aptlbs.cap new file mode 100644 index 0000000000000000000000000000000000000000..c7fc259b8118b41ee9f1e853a7e810af85bc5704 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbs/javacard/api_2_pah_aptlbs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/Api_2_Pah_Aptlbss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/Api_2_Pah_Aptlbss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3602cef071fa6a83de610b61abf2dc4827260b10 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/Api_2_Pah_Aptlbss_1.java @@ -0,0 +1,257 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Aptlbss_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbss; + +import javacard.framework.Util; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbss + * + * @version 0.0.1 - 21 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Aptlbss_1 extends TestToolkitApplet +{ + private byte compareBuffer[] = new byte[256] ; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Aptlbss_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Aptlbss_1 thisApplet = new Api_2_Pah_Aptlbss_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short value1 = 0 ; + short value2 = 0; + short length = 0 ; + short offset = 0 ; + byte[] buffer = new byte[256] ; + + // -------------------------------------------- + // Test Case 1 : handler overflow + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + offset = (short)0 ; + byte[] TempBuffer = new byte[(short)(proHdlr.getCapacity()-1)]; + Util.arrayFillNonAtomic(TempBuffer,(short)0,(short)TempBuffer.length,(byte)0); + proHdlr.appendArray(buffer, offset, (short)TempBuffer.length) ; + + // appendTLV + try { + proHdlr.appendTLV(tag,value1,value2) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.HANDLER_OVERFLOW) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : the current TLV is not modified + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select tag 02h + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Append TLV + proHdlr.appendTLV(tag,value1,value2) ; + + // Verify current TLV + result = proHdlr.getValueLength() ; + bRes = (result == (short)3) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Append TLV + tag = (byte)0x84 ; + value1 = (short)0x0001; + value2 = (short)0x0203; + proHdlr.appendTLV(tag,value1,value2); + + // Initialise compareBuffer + compareBuffer[0] = tag ; + compareBuffer[1] = (byte) 4; + compareBuffer[2] = (byte)(value1>>8 & (short)0x00FF) ; + compareBuffer[3] = (byte)(value1 & (short)0x00FF) ; + compareBuffer[4] = (byte)(value2>>8 & (short)0x00FF) ; + compareBuffer[5] = (byte)(value2 & (short)0x00FF) ; + + // Copy the handler + offset = (short)0 ; + length = (short)6 ; + proHdlr.copy(buffer, offset, length) ; + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Append TLV + tag = (byte)0x01 ; + value1 = (short)0xFEFD; + value2 = (short)0xFCFB; + proHdlr.appendTLV(tag,value1,value2); + + // Initialise compareBuffer + compareBuffer[6] = tag ; + compareBuffer[7] = (byte) 4; + compareBuffer[8] = (byte)(value1>>8 & (short)0x00FF); + compareBuffer[9] = (byte)(value1 & (short)0x00FF); + compareBuffer[10] = (byte)(value2>>8 & (short)0x00FF); + compareBuffer[11] = (byte)(value2 & (short)0x00FF); + + // Copy the handler + offset = (short)0 ; + length = (short)8 ; + proHdlr.copy(buffer, offset, length) ; + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (result == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 5 : successful call + testCaseNb = (byte) 5 ; + bRes = false ; + bRes2 = false ; + + try { + + // Clear the handler + proHdlr.clear() ; + + // Initialise buffers + for (short i=0; i<251; i++) { + buffer[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + buffer[1] = (byte)0x81 ; + buffer[2] = (byte)0xF7 ; + compareBuffer[1] = (byte)0x81 ; + compareBuffer[2] = (byte)0xF7 ; + tag = (byte)0x84 ; + value1 = (short)0x0001; + value2 = (short)0x0203; + compareBuffer[247] = tag ; + compareBuffer[248] = (byte) 4; + compareBuffer[249] = (byte)(value1>>8 & (short)0x00FF); + compareBuffer[250] = (byte)(value1 & (short)0x00FF); + compareBuffer[251] = (byte)(value2>>8 & (short)0x00FF); + compareBuffer[252] = (byte)(value2 & (short)0x00FF); + + // Initialise the handler + offset = (short)0 ; + length = (short)247 ; + proHdlr.appendArray(buffer, offset, length) ; + + // Append TLV + proHdlr.appendTLV(tag,value1,value2) ; + + // Verify length of the handler + bRes2 = (proHdlr.getLength() == (short)253) ; + + + // Copy the handler + offset = (short)0 ; + length = (short)proHdlr.getLength() ; + proHdlr.copy(buffer, offset, length) ; + + // Compare the handler + result = Util.arrayCompare(buffer, offset, compareBuffer, offset, length) ; + bRes = (bRes2) && (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/Test_Api_2_Pah_Aptlbss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/Test_Api_2_Pah_Aptlbss.java new file mode 100644 index 0000000000000000000000000000000000000000..8b68be06be72e3a439b085afa77cc463e520cefb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/Test_Api_2_Pah_Aptlbss.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Aptlbss.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_aptlbss; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_aptlbss + * + * @version 0.0.1 - 21 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Aptlbss extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_aptlbss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Aptlbss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a06d6f679c1332b18507dfcf86c77d0a3ace9b95 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_aptlbss.Api_2_Pah_Aptlbss_1 +uicc.test.toolkit.api_2_pah_aptlbss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/javacard/api_2_pah_aptlbss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/javacard/api_2_pah_aptlbss.cap new file mode 100644 index 0000000000000000000000000000000000000000..7bd14e88822c6161da9e2eac1687363d408300dd Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_aptlbss/javacard/api_2_pah_aptlbss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/Api_2_Pah_Cler_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/Api_2_Pah_Cler_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ae81dcdcf2c9f6445f07dc11e3e1d36f24340706 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/Api_2_Pah_Cler_1.java @@ -0,0 +1,120 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Cler_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_cler; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_cler + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Cler_1 extends TestToolkitApplet +{ + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Cler_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Cler_1 thisApplet = new Api_2_Pah_Cler_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + boolean bRes2 = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + short result = (short) 0 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Successful call + testCaseNb = (byte) 1 ; + bRes = false ; + bRes2 = false ; + + try { + + // Initialise the handler + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Select command Details TLV + proHdlr.findTLV(TAG_COMMAND_DETAILS, (byte)1) ; + + // Verify the length of the handler + bRes2 = (proHdlr.getLength() != 0) ; + + proHdlr.clear() ; + + // Verify the length of the handler + bRes = (bRes2) && (proHdlr.getLength() == 0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : A successful call resets the current TLV selected + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + proHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/Test_Api_2_Pah_Cler.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/Test_Api_2_Pah_Cler.java new file mode 100644 index 0000000000000000000000000000000000000000..ad551dde852ffe4c67e712fe8b4184d7093f1951 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/Test_Api_2_Pah_Cler.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Cler.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_cler; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_cler + * + * @version 0.0.1 - 17 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Cler extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_cler"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Cler() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 2 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "02CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..1a320b8aa427b844b3098d636f82de49efdca10e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_cler.Api_2_Pah_Cler_1 +uicc.test.toolkit.api_2_pah_cler +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/javacard/api_2_pah_cler.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/javacard/api_2_pah_cler.cap new file mode 100644 index 0000000000000000000000000000000000000000..11dcc76b0de5dd693e23f8ab37a817556903ce87 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cler/javacard/api_2_pah_cler.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/Api_2_Pah_Copy_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/Api_2_Pah_Copy_1.java new file mode 100644 index 0000000000000000000000000000000000000000..493dc79b0dc7158b422eacc6e3a3c9c0e68b120b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/Api_2_Pah_Copy_1.java @@ -0,0 +1,375 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Copy_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_copy; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_copy + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Copy_1 extends TestToolkitApplet +{ + private byte[] dstBuffer5 = new byte[5] ; + private byte[] dstBuffer9 = new byte[9] ; + private byte[] dstBuffer10 = new byte[10] ; + private byte[] dstBuffer15 = new byte[15] ; + private byte[] compareBuffer = new byte[15] ; + + private static final byte TYPE = (byte) 0x41 ; + private static final byte QUALIFIER = (byte) 0x42 ; + private static final byte DST_DEVICE = (byte) 0x43 ; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Copy_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Copy_1 thisApplet = new Api_2_Pah_Copy_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // Result of method + short result = 0 ; + + // -------------------------------------------- + // Test Case 1 : Null as dstBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.copy(null, (short)0, (short)1) ; + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : dstOffset > dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.copy(dstBuffer5, (short)6, (short)0) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + proHdlr.copy(dstBuffer5, (short)-1, (short)1) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + proHdlr.copy(dstBuffer5, (short)0, (short)6) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + proHdlr.copy(dstBuffer5, (short)3, (short)3) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + proHdlr.copy(dstBuffer5, (short)0, (short)-1) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : dstLength > length of the simple TLV list + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + try { + proHdlr.copy(dstBuffer10, (short)0, (short)dstBuffer10.length) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call, dstBuffer is the whole buffer + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + result = proHdlr.copy(dstBuffer9, (short)0, (short)dstBuffer9.length) ; + + bRes = (result == (short)9) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Compare the buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + // Initialise buffer + compareBuffer[0] = (byte) 0x81 ; + compareBuffer[1] = (byte) 0x03 ; + compareBuffer[2] = (byte) 0x01 ; + compareBuffer[3] = TYPE ; + compareBuffer[4] = QUALIFIER ; + compareBuffer[5] = (byte) 0x82 ; + compareBuffer[6] = (byte) 0x02 ; + compareBuffer[7] = (byte) 0x81 ; + compareBuffer[8] = DST_DEVICE ; + + try { + + result = javacard.framework.Util.arrayCompare(dstBuffer9, (short)0, compareBuffer, (short)0, (short)9) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successful call, dstBuffer is part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise dstBuffer + for (short i=0; i<(short)dstBuffer15.length; i++) { + dstBuffer15[i] = (byte)i ; + } + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + result = proHdlr.copy(dstBuffer15, (short)3, (short)9) ; + + bRes = (result == (short)12) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Compare the buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + // Initialise compareBuffer + for (short i=0; i<(short)compareBuffer.length; i++) { + compareBuffer[i] = (byte)i ; + } + + compareBuffer[3] = (byte) 0x81 ; + compareBuffer[4] = (byte) 0x03 ; + compareBuffer[5] = (byte) 0x01 ; + compareBuffer[6] = TYPE ; + compareBuffer[7] = QUALIFIER ; + compareBuffer[8] = (byte) 0x82 ; + compareBuffer[9] = (byte) 0x02 ; + compareBuffer[10] = (byte) 0x81 ; + compareBuffer[11] = DST_DEVICE ; + + try { + + result = javacard.framework.Util.arrayCompare(dstBuffer15, (short)0, compareBuffer, (short)0, (short)15) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successful call, dstBuffer is part of a buffer + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise dstBuffer + for (short i=0; i<(short)dstBuffer15.length; i++) { + dstBuffer15[i] = (byte)i ; + } + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + result = proHdlr.copy(dstBuffer15, (short)3, (short)6) ; + + bRes = (result == (short)9) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare the buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + // Initialise compareBuffer + for (short i=0; i<(short)compareBuffer.length; i++) { + compareBuffer[i] = (byte)i ; + } + + // Only 6 bytes + compareBuffer[3] = (byte) 0x81 ; + compareBuffer[4] = (byte) 0x03 ; + compareBuffer[5] = (byte) 0x01 ; + compareBuffer[6] = TYPE ; + compareBuffer[7] = QUALIFIER ; + compareBuffer[8] = (byte) 0x82 ; + + try { + + result = javacard.framework.Util.arrayCompare(dstBuffer15, (short)0, compareBuffer, (short)0, (short)15) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/Test_Api_2_Pah_Copy.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/Test_Api_2_Pah_Copy.java new file mode 100644 index 0000000000000000000000000000000000000000..ed47085a18237d9f85f432bd6eb4e62880a501cd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/Test_Api_2_Pah_Copy.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Copy.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_copy; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_copy + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Copy extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_copy"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Copy() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 13 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a950a84ecde1ddbb478b72629a694353458c4fd1 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_copy.Api_2_Pah_Copy_1 +uicc.test.toolkit.api_2_pah_copy +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/javacard/api_2_pah_copy.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/javacard/api_2_pah_copy.cap new file mode 100644 index 0000000000000000000000000000000000000000..e4b40b5f515fca9842aa209397bf67260bae36de Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_copy/javacard/api_2_pah_copy.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cprv/Api_2_Pah_Cprv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cprv/Api_2_Pah_Cprv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a492ec95366b91f3be34a900848e98160396e128 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_cprv/Api_2_Pah_Cprv_1.java @@ -0,0 +1,521 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Cprv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_cprv; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_cprv + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Cprv_1 extends TestToolkitApplet +{ + private byte TYPE = (byte) 0x21 ; + private byte QUALIFIER = (byte) 0x00 ; + private byte DST_DEVICE = (byte) 0x82 ; + + private byte[] TEXT = new byte[16] ; + private byte[] compareBuffer5 = new byte[5] ; + private byte[] compareBuffer15 = new byte[15] ; + private byte[] compareBuffer20 = new byte[20] ; + + private byte DCS_8_BIT_DATA = (byte) 0x04; + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Cprv_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Cprv_1 thisApplet = new Api_2_Pah_Cprv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // Result of method + short result = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null as compareBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + // Select a TLV + proHdlr.findTLV((byte)0x01, (byte)1) ; + + try { + proHdlr.compareValue((short)0, null, (short)0, (short)1) ; + + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : compareOffset >= compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)15) ; + + // Select Text String TLV + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.compareValue((short)0, compareBuffer5, (short)6, (short)0) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + proHdlr.compareValue((short)0, compareBuffer5, (short)-1, (short)1) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareLength > compareBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + proHdlr.compareValue((short)0, compareBuffer5, (short)0, (short)6) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + compareLength > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + proHdlr.compareValue((short)0, compareBuffer5, (short)3, (short)3) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compareLength < 0 + + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + proHdlr.compareValue((short)0, compareBuffer5, (short)3, (short)3) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.compareValue((short)7, compareBuffer15, (short)0, (short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.compareValue((short)-1, compareBuffer15, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : compareLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.compareValue((short)0, compareBuffer15, (short)0, (short)7) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + compareLength > Text String length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.compareValue((short)2, compareBuffer15, (short)0, (short)5) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable element + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.compareValue((short)0, compareBuffer15, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise Text buffer + for (short i=0; i= dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)15) ; + + // Select Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + try { + proHdlr.copyValue((short)0, dstBuffer5, (short)6, (short)0) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + proHdlr.copyValue((short)0, dstBuffer5, (short)-1, (short)1) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + proHdlr.copyValue((short)0, dstBuffer5, (short)0, (short)6) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + proHdlr.copyValue((short)0, dstBuffer5, (short)3, (short)3) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + proHdlr.copyValue((short)0, dstBuffer5, (short)3, (short)3) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.copyValue((short)7, dstBuffer15, (short)0, (short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.copyValue((short)-1, dstBuffer15, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : dstLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.copyValue((short)0, dstBuffer15, (short)0, (short)7) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + dstLength > Text String length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + proHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + proHdlr.copyValue((short)2, dstBuffer15, (short)0, (short)5) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable element + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.copyValue((short)0, dstBuffer15, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise Text buffer + for (short i=0; i compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)15) ; + + compareOffset = (short)21 ; + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, compareBuffer20, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + compareOffset = (short)-1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, compareBuffer20, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : length > compareBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + compareOffset = (short) 0 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, compareBuffer15, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + length > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + compareOffset = (short) 5 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, compareBuffer20, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Unavailable element + testCaseNb = (byte) 6 ; + bRes = false ; + bRes2 = false ; + + try { + // Initialise handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short) TEXT.length) ; + + // Select a TLV + proHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + // Search a wrong TLV + compareOffset = (short) 0 ; + try { + proHdlr.findAndCompareValue((byte)0x03, compareBuffer20, compareOffset) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no selected TLV + try { + proHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + // Initialise TEXT and compare buffer + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=0; i compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)15) ; + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)5 ; + compareLength = (short)1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)-1 ; + compareLength = (short)1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareLength > compareBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + compareLength > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)3 ; + compareLength = (short)3 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compareLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)-1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset > Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + + occurence = (byte)1 ; + valueOffset = (short)6 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)-1 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : compareLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)7 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + compareLength > Text String Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)0 ; + compareLength = (short)5 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Invalid parameter + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + occurence = (byte)0 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Unavailable Element + testCaseNb = (byte) 12 ; + bRes = false ; + bRes2 = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + + // Select a TLV + proHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + occurence = (byte)2 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + // FindAndCompareValue + try { + proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no selected TLV + try { + proHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successful call + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)TEXT.length; i++) { + TEXT[i] = (byte)i ; + compareBuffer17[(short)(i+1)] = (byte)i ; + } + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)16) ; + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)00) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Verify current TLV + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + result = proHdlr.getValueLength() ; + + bRes = (result == (short)17) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Successful call + testCaseNb = (byte) 15; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)TEXT.length; i++) { + compareBuffer17[(short)(i+1)] = (byte)i ; + } + compareBuffer17[16] = 0x10 ; + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)-1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successful call + testCaseNb = (byte) 16; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)TEXT.length; i++) { + compareBuffer17[(short)(i+1)] = (byte)i ; + } + compareBuffer17[0] = 0x03 ; + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)+1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Successful call + testCaseNb = (byte) 17; + bRes = false ; + + try { + + // Initialise buffers + Util.arrayFillNonAtomic(compareBuffer20,(short)0,(short)compareBuffer20.length,(byte)0x55); + for (short i=(short)3; i<(short)15; i++) { + compareBuffer20[i] = (byte)(i-2) ; + } + + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)3 ; + compareLength = (short)12 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer20, compareOffset, compareLength) ; + + bRes = (result == (short)0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successful call + testCaseNb = (byte) 18; + bRes = false ; + + try { + + // Initialise buffers + Util.arrayFillNonAtomic(compareBuffer20,(short)0,(short)compareBuffer20.length,(byte)0x55); + for (short i=(short)3; i<(short)15; i++) { + compareBuffer20[i] = (byte)(i-2) ; + } + compareBuffer20[3] = (byte)0x02 ; + compareBuffer20[4] = (byte)0x01 ; + + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)3 ; + compareLength = (short)12 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer20, compareOffset, compareLength) ; + + bRes = (result == (short)-1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 19 : Successful call + testCaseNb = (byte) 19; + bRes = false ; + + try { + + // Initialise buffers + Util.arrayFillNonAtomic(compareBuffer20,(short)0,(short)compareBuffer20.length,(byte)0x55); + for (short i=(short)3; i<(short)15; i++) { + compareBuffer20[i] = (byte)(i-2) ; + } + compareBuffer20[13] = (byte)0x0A ; + compareBuffer20[14] = (byte)0x0D ; + + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)3 ; + compareLength = (short)12 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer20, compareOffset, compareLength) ; + + bRes = (result == (short)+1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 20 : Successful call + testCaseNb = (byte)20 ; + bRes = false ; + + try { + + // Append a 2nd Text String TLV + TEXT[0] = (byte)0x00 ; + TEXT[1] = (byte)0x11 ; + TEXT[2] = (byte)0x22 ; + TEXT[3] = (byte)0x33 ; + TEXT[4] = (byte)0x44 ; + TEXT[5] = (byte)0x55 ; + + proHdlr.appendTLV(TAG_TEXT_STRING, TEXT, (short)0, (short)6) ; + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)TEXT.length; i++) { + compareBuffer17[(short)(i+1)] = (byte)i ; + } + + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 21 : Successful call + testCaseNb = (byte)21 ; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer[0] = (byte)0x00 ; + compareBuffer[1] = (byte)0x11 ; + compareBuffer[2] = (byte)0x22 ; + compareBuffer[3] = (byte)0x33 ; + compareBuffer[4] = (byte)0x44 ; + compareBuffer[5] = (byte)0x55 ; + + occurence = (byte)2 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer, compareOffset, compareLength) ; + + bRes = (result == (short)0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : Successful call + testCaseNb = (byte)22 ; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer[0] = (byte)0x00 ; + compareBuffer[1] = (byte)0x11 ; + compareBuffer[2] = (byte)0x22 ; + compareBuffer[3] = (byte)0x33 ; + compareBuffer[4] = (byte)0x44 ; + compareBuffer[5] = (byte)0x66 ; + + occurence = (byte)2 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + result = proHdlr.findAndCompareValue(TAG_TEXT_STRING, occurence, valueOffset, compareBuffer, compareOffset, compareLength) ; + + bRes = (result == (short)-1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 23 : Successful call : search tag 8Dh + testCaseNb = (byte) 23 ; + bRes = false ; + + // Initialise TEXT and compare buffer + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=0; i dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)15) ; + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, dstBuffer20, (short)21) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, dstBuffer20, (short)-1) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : length > dstBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, dstBuffer15, (short)0) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + length > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, dstBuffer20, (short)5) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Unavailable element + testCaseNb = (byte) 6 ; + bRes = false ; + bRes2 = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short) TEXT.length) ; + + // Select a TLV + proHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + try { + proHdlr.findAndCopyValue((byte)0x03, dstBuffer20, (short)0) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no current TLV + try { + proHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + // Initialise TEXT + for (short i=0; i dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)15) ; + + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)6 ; + dstLength = (short)0 ; + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)-1 ; + dstLength = (short)1 ; + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)0, dstBuffer5, (short)0, (short)6) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)0, dstBuffer5, (short)3, (short)3) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)0, dstBuffer5, (short)0, (short)-1) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)7, dstBuffer15, (short)0, (short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)-1, dstBuffer15, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : dstLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)0, dstBuffer15, (short)0, (short)7) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + dstLength > Text String Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)2, dstBuffer15, (short)0, (short)5) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable Element + testCaseNb = (byte) 11 ; + bRes = false ; + bRes2 = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short) TEXT.length) ; + + // Select a TLV + proHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + try { + proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)2, (short)0, dstBuffer15, (short)0, (short)1) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no current TLV + try { + proHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successful call + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + + // Initialise buffer + for (short i=0; i<(short)TEXT.length; i++) { + TEXT[i] = (byte)i ; + } + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)16) ; + + result = proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)0, dstBuffer17, (short)0, (short)17) ; + + bRes = (result == (short)17) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Initialise compare buffer + compareBuffer[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)16; i++) { + compareBuffer[(short)(i+1)] = (byte)i ; + } + + result = javacard.framework.Util.arrayCompare(compareBuffer, (short)0, dstBuffer17, (short)0, (short)17) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successful call + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + + for (short i=0; i<(short)20; i++) { + dstBuffer20[i] = (byte)0x55 ; + } + + result = proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)2, dstBuffer20, (short)3, (short)12) ; + + bRes = (result == (short)15) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Compare buffer + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + + // Initialise compare buffer + for (short i=0; i<(short)20; i++) { + compareBuffer[i] = (byte)0x55 ; + } + for (short i=3; i<(short)15; i++) { + compareBuffer[i] = (byte)(i-2) ; + } + + result = javacard.framework.Util.arrayCompare(compareBuffer, (short)0, dstBuffer20, (short)0, (short)20) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successful call with 2 Text String TLV + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + + // Append a Text String TLV + TEXT[0] = (byte) 0x00 ; + TEXT[1] = (byte) 0x11 ; + TEXT[2] = (byte) 0x22 ; + TEXT[3] = (byte) 0x33 ; + TEXT[4] = (byte) 0x44 ; + TEXT[5] = (byte) 0x55 ; + + proHdlr.appendTLV(TAG_TEXT_STRING, TEXT, (short)0, (short)6) ; + + result = proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)1, (short)0, dstBuffer17, (short)0, (short)17) ; + + bRes = (result == (short)17) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Compare buffer + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + + // Initialise compare buffer + compareBuffer[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)16; i++) { + compareBuffer[(short)(i+1)] = (byte)i ; + } + + result = javacard.framework.Util.arrayCompare(compareBuffer, (short)0, dstBuffer17, (short)0, (short)17) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successful call with 2 Text String TLV + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + + result = proHdlr.findAndCopyValue(TAG_TEXT_STRING, (byte)2, (short)0, dstBuffer17, (short)0, (short)6) ; + + bRes = (result == (short)6) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 19 : Compare buffer + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + + compareBuffer[0] = (byte) 0x00 ; + compareBuffer[1] = (byte) 0x11 ; + compareBuffer[2] = (byte) 0x22 ; + compareBuffer[3] = (byte) 0x33 ; + compareBuffer[4] = (byte) 0x44 ; + compareBuffer[5] = (byte) 0x55 ; + + result = javacard.framework.Util.arrayCompare(compareBuffer, (short)0, dstBuffer17, (short)0, (short)6) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 20 : Successful call, tag = 8Dh + testCaseNb = (byte) 20 ; + bRes = false ; + + // Initialise TEXT + for (short i=0; i 0x81) && (sCapacity <= 0x102)) + { + proHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 3)); + } + else if (sCapacity > 0x102) + { + proHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 4)); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // clear the handler + testCaseNb = (byte)0x03; + bRes = false; + try { + proHdlr.clear(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Fill the handler with the maximum capacity + 1 + testCaseNb = (byte)0x04; + bRes = false; + try { + if (sCapacity <= 0x81) + { + proHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 1)); + } + else if ((sCapacity > 0x81) && (sCapacity <= 0x102)) + { + proHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 2)); + } + else if (sCapacity > 0x102) + { + proHdlr.appendTLV((byte)0xAA, Buffer, (short)0x00, (short)(sCapacity - 3)); + } + bRes = false; + } + catch (ToolkitException e) { + if(e.getReason()==ToolkitException.HANDLER_OVERFLOW) + bRes = true ; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/Test_Api_2_Pah_Gcap.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/Test_Api_2_Pah_Gcap.java new file mode 100644 index 0000000000000000000000000000000000000000..68bd2edee34674010398561f53f63a362d6d821a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/Test_Api_2_Pah_Gcap.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Gcap.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gcap; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gcap + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Gcap extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_gcap"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Gcap() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "04CCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..1f6c2f348dd301b42315941983a3d31b6e5bd924 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_gcap.Api_2_Pah_Gcap_1 +uicc.test.toolkit.api_2_pah_gcap +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/javacard/api_2_pah_gcap.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/javacard/api_2_pah_gcap.cap new file mode 100644 index 0000000000000000000000000000000000000000..aadf0f23bb2e2c4c59e2babb9ce5675d834103c7 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gcap/javacard/api_2_pah_gcap.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/Api_2_Pah_Glen_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/Api_2_Pah_Glen_1.java new file mode 100644 index 0000000000000000000000000000000000000000..550fb42d2dac7804115a521eb9c45582791431bf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/Api_2_Pah_Glen_1.java @@ -0,0 +1,162 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Glen_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_glen; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import javacard.framework.Util; +import uicc.toolkit.*; +import uicc.test.util.*; + +/** + * Test Area : uicc.test.toolkit.api_2_pah_glen + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Glen_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + private byte TYPE = (byte) 0x41 ; + private byte QUALIFIER = (byte) 0x42 ; + private byte DST_DEVICE = (byte) 0x43 ; + private byte DCS_8_BIT_DATA = (byte) 0x04; + /** + * Constructor of the applet + */ + public Api_2_Pah_Glen_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Glen_1 thisApplet = new Api_2_Pah_Glen_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + byte[] Text = new byte[240]; + Util.arrayFillNonAtomic(Text,(short)0,(short)Text.length,(byte)0); + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : Clear the handler + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + proHdlr.clear(); + if (proHdlr.getLength()==0) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : Call the init() method + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE); + if (proHdlr.getLength()== (short)0x0009) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : InitDisplayText with Text length = 240 + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, Text, (short)0, (short)0x00F0) ; + if (proHdlr.getLength()== (short)0x00FD) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 3 : + // -------------------------------------------- + // Test Case 4 : Build a 7Fh length proactive command. + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, Text, (short)0, (short)0x0073) ; + if (proHdlr.getLength()== (short) 0x007F ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 4 : + // -------------------------------------------- + // Test Case 5 : Build a 80h length proactive command. + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, Text, (short)0, (short)0x0074) ; + if (proHdlr.getLength()== (short) 0x0080 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/Test_Api_2_Pah_glen.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/Test_Api_2_Pah_glen.java new file mode 100644 index 0000000000000000000000000000000000000000..60013d292f2dc0bd36b5bc5e7d7bd750622f4f68 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/Test_Api_2_Pah_glen.java @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_glen.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_glen; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.api_2_pah_glen + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_glen extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_glen"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Pah_glen() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH,CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + for(byte i = 0;i<5;i++) + { + // Send Unrecognized Envelope + response = test.unrecognizedEnvelope(); + result = response.checkSw("90 00"); + } + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..427eca979ce8ff379e4a263cc144fb949bbc75e9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_glen.Api_2_Pah_Glen_1 +uicc.test.toolkit.api_2_pah_glen +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/javacard/api_2_pah_glen.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/javacard/api_2_pah_glen.cap new file mode 100644 index 0000000000000000000000000000000000000000..dd746092870a89326d91722cf82a3a2b8455492c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_glen/javacard/api_2_pah_glen.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/Api_2_Pah_Gvby_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/Api_2_Pah_Gvby_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b6bf2e8f77a26ab86eb7053fe0c4c87312ece6bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/Api_2_Pah_Gvby_1.java @@ -0,0 +1,256 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Gvby_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gvby; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gvby + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Gvby_1 extends TestToolkitApplet +{ + private byte TYPE = (byte) 0xFF ; + private byte QUALIFIER = (byte) 0xFE ; + private byte DST_DEVICE = (byte) 0xFD ; + + private byte[] TEXT = new byte[240] ; + private byte DCS_8_BIT_DATA = (byte) 0x04; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Gvby_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Gvby_1 thisApplet = new Api_2_Pah_Gvby_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // Result of method + short result = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.getValueByte((short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Out of Tlv Boundaries + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Search Command Details TLV + proHdlr.findTLV((byte)0x01, (byte)1) ; + + try { + result = proHdlr.getValueByte((short)3) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Search Command Details TLV + proHdlr.findTLV((byte)0x01, (byte)1) ; + + // Get Qualifier + result = proHdlr.getValueByte((short)2) ; + + bRes = (result == QUALIFIER) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Search Device Identities TLV + proHdlr.findTLV((byte)0x02, (byte)1) ; + + // Get Source Device + result = proHdlr.getValueByte((short)0) ; + + bRes = (result == (byte)0x81) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // Initialise Text buffer + for (short i=0; i<(short)TEXT.length; i++) { + TEXT[i] = (byte) i ; + } + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Initialise handler + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)0x7E) ; + + // Find Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + result = proHdlr.getValueByte((short)0x7E) ; + + bRes = (result == (byte)0x7D) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + // Initialise handler + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)0x7F) ; + + // Find Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + result = proHdlr.getValueByte((short)0x7E) ; + + bRes = (result == (byte)0x7D) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + result = proHdlr.getValueByte((short)0x7F) ; + + bRes = (result == (byte)0x7E) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + // Initialise handler + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)0xF0) ; + + // Find Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + result = proHdlr.getValueByte((short)0xF0) ; + + bRes = (result == (byte)0xEF) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/Test_Api_2_Pah_Gvby.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/Test_Api_2_Pah_Gvby.java new file mode 100644 index 0000000000000000000000000000000000000000..5b12f7bf1da8544da40e0eda7d98e4a8561aa585 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/Test_Api_2_Pah_Gvby.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Gvby.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gvby; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gvby + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Gvby extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_gvby"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Gvby() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 8 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3543d297b7c3cfbf8c0ef66aedef1ffae4f301ac --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_gvby.Api_2_Pah_Gvby_1 +uicc.test.toolkit.api_2_pah_gvby +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/javacard/api_2_pah_gvby.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/javacard/api_2_pah_gvby.cap new file mode 100644 index 0000000000000000000000000000000000000000..695780722b0ee07f63603acab44e82d33ef12198 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvby/javacard/api_2_pah_gvby.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/Api_2_Pah_Gvle_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/Api_2_Pah_Gvle_1.java new file mode 100644 index 0000000000000000000000000000000000000000..c382e0e08958aa4a00d45ca02d3ab933e8352d81 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/Api_2_Pah_Gvle_1.java @@ -0,0 +1,229 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Gvle_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gvle; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gvle + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Gvle_1 extends TestToolkitApplet +{ + private byte TYPE = (byte) 0x21 ; + private byte QUALIFIER = (byte) 0x00 ; + private byte DST_DEVICE = (byte) 0x82 ; + + private byte[] TEXT = new byte[240] ; + + private byte[] buffer1 = new byte[1]; + private byte DCS_8_BIT_DATA = (byte) 0x04; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Gvle_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Gvle_1 thisApplet = new Api_2_Pah_Gvle_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + byte tag = 0 ; + short ValueOffset = 0 ; + short ValueLength = 0 ; + + // Result of method + short result = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.getValueLength() ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Successful call + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + tag = (byte) (0x0D) ; + ValueOffset = (short)0 ; + ValueLength = (short)0 ; + + proHdlr.appendTLV(tag, buffer1, ValueOffset, ValueLength) ; + + // Search Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + result = proHdlr.getValueLength() ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)1) ; + + // Search Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + result = proHdlr.getValueLength() ; + + bRes = (result == (short)2) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)0x7E) ; + + // Search Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + result = proHdlr.getValueLength() ; + + bRes = (result == (short)0x7F) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)0x7F) ; + + // Search Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + result = proHdlr.getValueLength() ; + + bRes = (result == (short)0x80) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.initDisplayText(QUALIFIER, DCS_8_BIT_DATA, TEXT, (short)0, (short)0xF0) ; + + // Search Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + // Get length + result = proHdlr.getValueLength() ; + + bRes = (result == (short)0xF1) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/Test_Api_2_Pah_Gvle.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/Test_Api_2_Pah_Gvle.java new file mode 100644 index 0000000000000000000000000000000000000000..7efba8c1cce373cf5a7693798166664f1d3471ff --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/Test_Api_2_Pah_Gvle.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Gvle.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gvle; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gvle + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Gvle extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_gvle"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Gvle() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 6 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..91663e5975763a09c7cd43c266aa389e3b304640 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_gvle.Api_2_Pah_Gvle_1 +uicc.test.toolkit.api_2_pah_gvle +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/javacard/api_2_pah_gvle.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/javacard/api_2_pah_gvle.cap new file mode 100644 index 0000000000000000000000000000000000000000..1202b723f5b12a2d21561c007ebcf0a1ce2c6631 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvle/javacard/api_2_pah_gvle.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/Api_2_Pah_Gvsh_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/Api_2_Pah_Gvsh_1.java new file mode 100644 index 0000000000000000000000000000000000000000..37aa6242a0ddeed2959e4c88ef157f1e2ff6a3b9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/Api_2_Pah_Gvsh_1.java @@ -0,0 +1,257 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Gvsh_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gvsh; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gvsh + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Gvsh_1 extends TestToolkitApplet +{ + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte)0; + + private static final byte DCS_8_BIT_DATA = 0x04; + + private static final byte TYPE = (byte) 0xFF ; + private static final byte QUALIFIER = (byte) 0xFE ; + private static final byte DST_DEVICE = (byte) 0xFD ; + + private byte[] TEXT = new byte[240] ; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Gvsh_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Gvsh_1 thisApplet = new Api_2_Pah_Gvsh_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // Result of method + short result = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Initialise the handler + proHdlr.init(TYPE, QUALIFIER, DST_DEVICE) ; + + try { + proHdlr.getValueShort((short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Out of Tlv Boundaries + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Search Command Details TLV + proHdlr.findTLV((byte)0x01, (byte)1) ; + + try { + result = proHdlr.getValueShort((short)3) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Search Command Details TLV + proHdlr.findTLV((byte)0x01, (byte)1) ; + + // Get Qualifier + result = proHdlr.getValueShort((short)1) ; + + bRes = (result == (short)0xFFFE) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Search Device Identities TLV + proHdlr.findTLV((byte)0x02, (byte)1) ; + + // Get Source Device + result = proHdlr.getValueShort((short)0) ; + + bRes = (result == (short)0x81FD) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Initialise Text buffer + for (short i=0; i<(short)TEXT.length; i++) { + TEXT[i] = (byte) i ; + } + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Initialise handler + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)0x7E) ; + + // Find Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + result = proHdlr.getValueShort((short)0x7D) ; + + bRes = (result == (short)0x7C7D) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + // Initialise handler + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)0x7F) ; + + // Find Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + result = proHdlr.getValueShort((short)0x7D) ; + + bRes = (result == (short)0x7C7D) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + result = proHdlr.getValueShort((short)0x7E) ; + + bRes = (result == (short)0x7D7E) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + // Initialise handler + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)0xF0) ; + + // Find Text String TLV + proHdlr.findTLV((byte)0x0D, (byte)1) ; + + result = proHdlr.getValueShort((short)0xEF) ; + + bRes = (result == (short)0xEEEF) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/Test_Api_2_Pah_Gvsh.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/Test_Api_2_Pah_Gvsh.java new file mode 100644 index 0000000000000000000000000000000000000000..45e5c847772d2599b03528d39674493992af67bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/Test_Api_2_Pah_Gvsh.java @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Gvsh.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_gvsh; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_gvsh + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Gvsh extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_gvsh"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Gvsh() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 8 */ + /*********************************************************************/ + + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4bfa4f3df828e4b5cc5819c177428684ba87b35b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_gvsh.Api_2_Pah_Gvsh_1 +uicc.test.toolkit.api_2_pah_gvsh +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/javacard/api_2_pah_gvsh.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/javacard/api_2_pah_gvsh.cap new file mode 100644 index 0000000000000000000000000000000000000000..d72243b00119d873c9df28e7e22d7cd6f6242929 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_gvsh/javacard/api_2_pah_gvsh.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/Api_2_Pah_Icch_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/Api_2_Pah_Icch_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7b7370347e0bc2f84453ec178f0e79be371a93c9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/Api_2_Pah_Icch_1.java @@ -0,0 +1,160 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Icch_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_icch; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_icch + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Icch_1 extends TestToolkitApplet +{ + + // Result of tests + boolean bRes ; + + public final static byte CHANNEL_ID1 = (byte)0x01; + public final static byte CHANNEL_ID2 = (byte)0x02; + public final static byte QUALIFIER_1 = (byte)0x01; + public static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + public static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + public static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + + // Number of tests + byte testCaseNb = (byte)0; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Icch_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Icch_1 thisApplet = new Api_2_Pah_Icch_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register on EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS); + } + + public void processToolkit(short event) + { + // Result of each test + bRes = false ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + // Open a channel + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + proHdlr.send(); + } + + + if (event == EVENT_EVENT_DOWNLOAD_CHANNEL_STATUS) { + switch(testCaseNb) { + case (byte)0 : + // -------------------------------------------- + // Test Case 1 : initCloseChannel + testCaseNb = (byte) 1 ; + try { + proHdlr.initCloseChannel(CHANNEL_ID1); + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + // -------------------------------------------- + // Test Case 2 : + case (byte)1 : + testCaseNb = (byte) 2 ; + try { + proHdlr.initCloseChannel(CHANNEL_ID2); + proHdlr.initCloseChannel(CHANNEL_ID1); + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + // -------------------------------------------- + // Test Case 3 : + case (byte)2 : + testCaseNb = (byte) 3 ; + try { + proHdlr.findTLV(TAG_ADDRESS,(byte)1); + proHdlr.initCloseChannel(CHANNEL_ID1); + short i = proHdlr.getValueLength(); + bRes = false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + try { + proHdlr.send(); + } + catch (Exception e) {} + reportTestOutcome(testCaseNb, bRes); + break; + + // -------------------------------------------- + // Test Case 4 : + case (byte)3 : + testCaseNb = (byte) 4 ; + try { + proHdlr.initCloseChannel(CHANNEL_ID1); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + } + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/Test_Api_2_Pah_Icch.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/Test_Api_2_Pah_Icch.java new file mode 100644 index 0000000000000000000000000000000000000000..82b8f2ba15c385c817258a7c3480a38e740c188c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/Test_Api_2_Pah_Icch.java @@ -0,0 +1,200 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Icch.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_icch; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_icch + * + * @version 0.0.1 - 20 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Icch extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_icch"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Icch() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("911A"); + + // Fetch the Open Channel proactive command + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + // Successful terminal response + test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + + // Send an EVENT_DOWNLOAD_CHANNEL_STATUS Envelope + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("910B"); + // Fetch the close channel proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Successful terminal response + response = test.terminalResponse("81030141 00820282 81830100"); + result &= response.checkSw("9000"); + + // Send an EVENT_DOWNLOAD_CHANNEL_STATUS Envelope + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911A"); + + // Fetch the open channel proactive command + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + // Successful terminal response + test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + + // Send an EVENT_DOWNLOAD_CHANNEL_STATUS Envelope + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("910B"); + // Fetch the close channel proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Successful terminal response + response = test.terminalResponse("81030141 00820282 81830100"); + result &= response.checkSw("9000"); + + // Send an EVENT_DOWNLOAD_CHANNEL_STATUS Envelope + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911A"); + + // Fetch the open channel proactive command + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + // Successful terminal response + test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + + // Send an EVENT_DOWNLOAD_CHANNEL_STATUS Envelope + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("910B"); + // Fetch the close channel proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Successful terminal response + response = test.terminalResponse("81030141 00820282 81830100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911A"); + + // Fetch the open channel proactive command + response = test.fetch("1A"); + result &= response.checkData("D0188103 01400182 02818206 05815566" + + "77883502 03003902 000A"); + // Successful terminal response + test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + + // Send an EVENT_DOWNLOAD_CHANNEL_STATUS Envelope + response = test.envelopeEventDownloadChannelStatus("38028100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "04CCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..4a535942a85bd7977ed966b87444e16761b30f0d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_icch.Api_2_Pah_Icch_1 +uicc.test.toolkit.api_2_pah_icch +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/javacard/api_2_pah_icch.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/javacard/api_2_pah_icch.cap new file mode 100644 index 0000000000000000000000000000000000000000..f7a29dc5e5db8e179481dd6e0ddce3a96514a5bb Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_icch/javacard/api_2_pah_icch.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/Api_2_Pah_Indt_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/Api_2_Pah_Indt_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ac93fc8d38f6d9ef5a765523f63057fd5d579d31 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/Api_2_Pah_Indt_1.java @@ -0,0 +1,479 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Indt.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_indt; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_indt + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Indt_1 extends TestToolkitApplet +{ + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + private byte[] TEXTA = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'A'} ; + private byte[] TEXTB = {(byte)'1',(byte)'2',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'B'} ; + private byte[] TEXTC = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'C',(byte)'1',(byte)'2'} ; + private byte[] TEXTD = {(byte)'1',(byte)'2',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'D',(byte)'3',(byte)'4'} ; + private byte[] TEXTE = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'E'} ; + private byte[] TEXTF = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'F'} ; + private byte[] TEXTG = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'G'} ; + private byte[] TEXTH = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'H',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'H'} ; + private byte[] LONGTEXT = new byte[256] ; + + private static final short MAXIMUM_SIZE = (short) (241) ; + + private byte[] destination = new byte[9] ; + + private byte DCS_8_BIT_DATA = (byte) 0x04; + private byte DCS_DEFAULT_ALPHABET = (byte)0; + private byte DCS_UCS2 = (byte)0x08; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Indt_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Indt_1 thisApplet = new Api_2_Pah_Indt_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : NULL as parameter to buffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, null, (short)0, (short)1) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : offset > buffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)5, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : length > buffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : offset + length > buffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)3, (short)2) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 6 : length < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)3, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Successful call, whole buffer + // Verify the command number + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5) ; + + // Get command number + proHdlr.copy(destination, (short)0, (short)9) ; + short commandNumber = (short) (destination[2] & (short)0xFF) ; + + bRes = ((commandNumber>=(short)0x01) && (commandNumber<=(short)0xFE)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : Send the command + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + proHdlr.send() ; + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 9 : Successful call, part of a buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTB, (short)2, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 10 : Successful call, part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTC, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 11 : Successful call, part of a buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTD, (short)2, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 12 : Successful call, qualifier = 81 + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x81, DCS_8_BIT_DATA, TEXTE, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 13 : Successful call, DCS = 0 + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_DEFAULT_ALPHABET , TEXTF, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 14 : Successful call, DCS = 8 + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_UCS2 , TEXTG, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 15 : Test initialisation of the handler + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5) ; + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTH, (short)0, (short)10) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 16 : Successful call, text length is zero + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTH, (short)0, (short)0) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 17 : no TLV is selected after the method invocation + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + + // Select 1st TLV of the handler + proHdlr.findTLV((byte)1, (byte)1) ; + + // Method invocation + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5) ; + + try { + short length = proHdlr.getValueLength() ; + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } + catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // Prepare buffer + + for (short i=(short)0; i<(short)LONGTEXT.length; i++) { + LONGTEXT[i] = (byte) 0x55 ; + } + + // -------------------------------------------- + // Test Case 18 : initDisplayText with buffer length = 7Eh + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x7E) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true); ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); ; + } + + // -------------------------------------------- + // Test Case 19 : initDisplayText with buffer length = 7Fh + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x7F) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true); ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); ; + } + + // -------------------------------------------- + // Test Case 20 : initDisplayText with buffer length = 240 + testCaseNb = (byte) 20 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)240) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true); ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); ; + } + + // -------------------------------------------- + // Test Case 21 : initDisplayText with a too long buffer + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, MAXIMUM_SIZE) ; + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.HANDLER_OVERFLOW) { + bRes = true ; + } + } + } catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : initDisplayText without sending the command + testCaseNb = (byte) 22 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)10) ; + + // Command successfull + reportTestOutcome(testCaseNb,true); + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/Test_Api_2_Pah_Indt.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/Test_Api_2_Pah_Indt.java new file mode 100644 index 0000000000000000000000000000000000000000..4147a7ab4f4b8b2bda4e8b3e77255b512f05cafa --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/Test_Api_2_Pah_Indt.java @@ -0,0 +1,242 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Indt.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_indt; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_indt + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Indt extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_indt"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Pah_Indt() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 8 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9113"); + + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06045465" + + "787441"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 9 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06045465" + + "787442"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06045465" + + "787443"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 11 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06045465" + + "787444"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 12 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01218182 0281028D 06045465" + + "787445"); + response = test.terminalResponse("81030121 81020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06005465" + + "787446"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 14 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01210082 0281028D 06085465" + + "787447"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9118"); + + /*********************************************************************/ + /** Testcase 15 */ + /*********************************************************************/ + response = test.fetch("18"); + result &= response.checkData("D0168103 01210082 0281028D 0B045465" + + "78744854 65787448"); + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("910D"); + + /*********************************************************************/ + /** Testcase 16 */ + /*********************************************************************/ + response = test.fetch("0D"); + result &= response.checkData("D00B8103 01210082 0281028D 00"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("918D"); + + /*********************************************************************/ + /** Testcase 17,18 */ + /*********************************************************************/ + response = test.fetch("8D"); + result &= response.checkData("D0818A81 03012100 82028102 8D7F0455" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("918F"); + + /*********************************************************************/ + /** Testcase 19 */ + /*********************************************************************/ + response = test.fetch("8F"); + result &= response.checkData("D0818C81 03012100 82028102 8D818004" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 555555"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9100"); + + /*********************************************************************/ + /** Testcase 20,21,22 */ + /*********************************************************************/ + response = test.fetch("00"); + result &= response.checkData("D081FD81 03012100 82028102 8D81F104" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "16CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b47867509dd93502736602e79d4b710398fdd941 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_indt.Api_2_Pah_Indt_1 +uicc.test.toolkit.api_2_pah_indt +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/javacard/api_2_pah_indt.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/javacard/api_2_pah_indt.cap new file mode 100644 index 0000000000000000000000000000000000000000..51dc6ebef20298c2758493708067dc81092846d8 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_indt/javacard/api_2_pah_indt.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/Api_2_Pah_Ingk_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/Api_2_Pah_Ingk_1.java new file mode 100644 index 0000000000000000000000000000000000000000..9d4419126cfd54cdc8471145ad8184e594f6c63c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/Api_2_Pah_Ingk_1.java @@ -0,0 +1,479 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Ingk.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_ingk; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_ingk + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Ingk_1 extends TestToolkitApplet +{ + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + private byte[] TEXTA = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'A'} ; + private byte[] TEXTB = {(byte)'1',(byte)'2',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'B'} ; + private byte[] TEXTC = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'C',(byte)'1',(byte)'2'} ; + private byte[] TEXTD = {(byte)'1',(byte)'2',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'D',(byte)'3',(byte)'4'} ; + private byte[] TEXTE = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'E'} ; + private byte[] TEXTF = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'F'} ; + private byte[] TEXTG = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'G'} ; + private byte[] TEXTH = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'H',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'H'} ; + private byte[] LONGTEXT = new byte[256] ; + + private static final short MAXIMUM_SIZE = (short) (241) ; + + private byte[] destination = new byte[9] ; + + private byte DCS_8_BIT_DATA = (byte) 0x04; + private byte DCS_DEFAULT_ALPHABET = (byte)0; + private byte DCS_UCS2 = (byte)0x08; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Ingk_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Ingk_1 thisApplet = new Api_2_Pah_Ingk_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : NULL as parameter to buffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, null, (short)0, (short)1) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : offset > buffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)5, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : length > buffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)5) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : offset + length > buffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)3, (short)2) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 6 : length < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)3, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Successful call, whole buffer + // Verify the command number + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5) ; + + // Get command number + proHdlr.copy(destination, (short)0, (short)9) ; + short commandNumber = (short) (destination[2] & (short)0xFF) ; + + bRes = ((commandNumber>=(short)0x01) && (commandNumber<=(short)0xFE)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : Send the command + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + proHdlr.send() ; + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 9 : Successful call, part of a buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTB, (short)2, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 10 : Successful call, part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTC, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 11 : Successful call, part of a buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTD, (short)2, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 12 : Successful call, qualifier = 81 + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x81, DCS_8_BIT_DATA, TEXTE, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 13 : Successful call, DCS = 0 + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_DEFAULT_ALPHABET , TEXTF, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 14 : Successful call, DCS = 8 + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_UCS2 , TEXTG, (short)0, (short)5) ; + proHdlr.send() ; + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 15 : Test initialisation of the handler + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5) ; + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTH, (short)0, (short)10) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 16 : Successful call, text length is zero + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTH, (short)0, (short)0) ; + proHdlr.send() ; + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb,bRes); + + // -------------------------------------------- + // Test Case 17 : no TLV is selected after the method invocation + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + + // Select 1st TLV of the handler + proHdlr.findTLV((byte)1, (byte)1) ; + + // Method invocation + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5) ; + + try { + short length = proHdlr.getValueLength() ; + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } + catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // Prepare buffer + + for (short i=(short)0; i<(short)LONGTEXT.length; i++) { + LONGTEXT[i] = (byte) 0x55 ; + } + + // -------------------------------------------- + // Test Case 18 : initGetInkey with buffer length = 7Eh + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x7E) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true); ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); ; + } + + // -------------------------------------------- + // Test Case 19 : initGetInkey with buffer length = 7Fh + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x7F) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true); ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); ; + } + + // -------------------------------------------- + // Test Case 20 : initGetInkey with buffer length = 240 + testCaseNb = (byte) 20 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)240) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true); ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); ; + } + + // -------------------------------------------- + // Test Case 21 : initGetInkey with a too long buffer + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + try { + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, MAXIMUM_SIZE) ; + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.HANDLER_OVERFLOW) { + bRes = true ; + } + } + } catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : initGetInkey without sending the command + testCaseNb = (byte) 22 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInkey((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)10) ; + + // Command successfull + reportTestOutcome(testCaseNb,true); + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/Test_Api_2_Pah_Ingk.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/Test_Api_2_Pah_Ingk.java new file mode 100644 index 0000000000000000000000000000000000000000..64d9aaf653867afc7cbea6ca6fc55e3df4ef6470 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/Test_Api_2_Pah_Ingk.java @@ -0,0 +1,242 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Ingk.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_ingk; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_ingk + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Ingk extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_ingk"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Pah_Ingk() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 8 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9113"); + + response = test.fetch("13"); + result &= response.checkData("D0118103 01220082 0281828D 06045465" + + "787441"); + + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 9 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01220082 0281828D 06045465" + + "787442"); + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01220082 0281828D 06045465" + + "787443"); + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 11 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01220082 0281828D 06045465" + + "787444"); + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 12 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01228182 0281828D 06045465" + + "787445"); + response = test.terminalResponse("81030122 81020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01220082 0281828D 06005465" + + "787446"); + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9113"); + + /*********************************************************************/ + /** Testcase 14 */ + /*********************************************************************/ + response = test.fetch("13"); + result &= response.checkData("D0118103 01220082 0281828D 06085465" + + "787447"); + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9118"); + + /*********************************************************************/ + /** Testcase 15 */ + /*********************************************************************/ + response = test.fetch("18"); + result &= response.checkData("D0168103 01220082 0281828D 0B045465" + + "78744854 65787448"); + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("910D"); + + /*********************************************************************/ + /** Testcase 16 */ + /*********************************************************************/ + response = test.fetch("0D"); + result &= response.checkData("D00B8103 01220082 0281828D 00"); + + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("918D"); + + /*********************************************************************/ + /** Testcase 17,18 */ + /*********************************************************************/ + response = test.fetch("8D"); + result &= response.checkData("D0818A81 03012200 82028182 8D7F0455" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55"); + + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("918F"); + + /*********************************************************************/ + /** Testcase 19 */ + /*********************************************************************/ + response = test.fetch("8F"); + result &= response.checkData("D0818C81 03012200 82028182 8D818004" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 555555"); + + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9100"); + + /*********************************************************************/ + /** Testcase 20,21,22 */ + /*********************************************************************/ + response = test.fetch("00"); + result &= response.checkData("D081FD81 03012200 82028182 8D81F104" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555"); + + response = test.terminalResponse("81030122 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "16CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..235310ead21e2bcf1e35894bb0feda4c6a5d5b1c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_ingk.Api_2_Pah_Ingk_1 +uicc.test.toolkit.api_2_pah_ingk +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/javacard/api_2_pah_ingk.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/javacard/api_2_pah_ingk.cap new file mode 100644 index 0000000000000000000000000000000000000000..7b62faef1c078164a73acc5568c8db12914d2604 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingk/javacard/api_2_pah_ingk.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/Api_2_Pah_Ingp_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/Api_2_Pah_Ingp_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5c24d915d84daaea5702c188c4ff7fe7436709d4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/Api_2_Pah_Ingp_1.java @@ -0,0 +1,472 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Ingp_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_ingp; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_ingp + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Ingp_1 extends TestToolkitApplet +{ + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + private byte[] TEXTA = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'A'} ; + private byte[] TEXTB = {(byte)'1',(byte)'2',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'B'} ; + private byte[] TEXTC = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'C',(byte)'1',(byte)'2'} ; + private byte[] TEXTD = {(byte)'1',(byte)'2',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'D',(byte)'3',(byte)'4'} ; + private byte[] TEXTE = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'E'} ; + private byte[] TEXTF = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'F'} ; + private byte[] TEXTG = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'G'} ; + private byte[] TEXTH = {(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'H',(byte)'T',(byte)'e',(byte)'x',(byte)'t',(byte)'H'} ; + private byte[] LONGTEXT = new byte[256] ; + + private static final short MAXIMUM_SIZE = (short) (241) ; + + private byte[] destination = new byte[9] ; + + private byte DCS_8_BIT_DATA = (byte) 0x04; + private byte DCS_DEFAULT_ALPHABET = (byte)0; + private byte DCS_UCS2 = (byte)0x08; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Ingp_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Ingp_1 thisApplet = new Api_2_Pah_Ingp_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : NULL as parameter to buffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, null, (short)0, (short)1, (short)0, (short)0) ; + } + catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : offset > buffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)5, (short)1, (short)0, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : offset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)-1, (short)1, (short)0, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : length > buffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)5, (short)0, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : offset + length > buffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)3, (short)2, (short)0, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 6 : length < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)3, (short)-1, (short)0, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Successful call, whole buffer + // Verify the command number + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5, (short)0, (short)0xFF) ; + + // Get command number + proHdlr.copy(destination, (short)0, (short)9) ; + short commandNumber = (short) (destination[2] & (short)0xFF) ; + + bRes = ((commandNumber>=(short)0x01) && (commandNumber<=(short)0xFE)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : Send the command + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 9 : Successful call, part of a buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTB, (short)2, (short)5, (short)0x10, (short)0xff) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 10 : Successful call, part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTC, (short)0, (short)5, (short)0xff, (short)0xff) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 11 : Successful call, part of a buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTD, (short)2, (short)5, (short)0, (short)0) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 12 : Successful call, qualifier = 81 + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x81, DCS_8_BIT_DATA, TEXTE, (short)0, (short)5, (short)0, (short)0x10) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 13 : Successful call, DCS = 0 + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_DEFAULT_ALPHABET , TEXTF, (short)0, (short)5, (short)0x10, (short)0x10) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 14 : Successful call, DCS = 8 + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_UCS2 , TEXTG, (short)0, (short)5, (short)0x00, (short)0xff) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 15 : Test initialisation of the handler + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + //proHdlr.init((byte)0xFF, (byte)0xFF, (byte)0xFF) ; + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5, (short)0, (short)0x10) ; + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTH, (short)0, (short)10, (short)0, (short)0x10) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 16 : Successful call, null text string + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTH, (short)0, (short)0, (short)0, (short)0x10) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 17 : no TLV is selected after the method invocation + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + + // Select 1st TLV of the handler + proHdlr.findTLV((byte)1, (byte)1) ; + + // Method invocation + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXTA, (short)0, (short)5, (short)0, (short)0x10) ; + + try { + short length = proHdlr.getValueLength() ; + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } + catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // Prepare buffer + + for (short i=(short)0; i<(short)LONGTEXT.length; i++) { + LONGTEXT[i] = (byte) 0x55 ; + } + + // -------------------------------------------- + // Test Case 18 : initGetInput with buffer length = 7Eh + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x7E, (short)0, (short)0x10) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 19 : initGetInput with buffer length = 7Fh + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x7F, (short)0, (short)0x10) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 20 : initGetInput with buffer length = 237 + testCaseNb = (byte) 20 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)236, (short)0, (short)0x10) ; + + // Send the command + proHdlr.send() ; + + // Command successfull + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 21 : initGetInput with a too long buffer + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + try { + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, MAXIMUM_SIZE, (short)0, (short)0x10) ; + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.HANDLER_OVERFLOW) { + bRes = true ; + } + } + } catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : initGetInput without sending the command + testCaseNb = (byte) 22 ; + bRes = false ; + + try { + // Initialize the command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)10, (short)0, (short)0x10) ; + + // Command successfull + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/Test_Api_2_Pah_Ingp.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/Test_Api_2_Pah_Ingp.java new file mode 100644 index 0000000000000000000000000000000000000000..9941c6f4d164aab47b936112edc36cc8607c9ae2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/Test_Api_2_Pah_Ingp.java @@ -0,0 +1,245 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Ingp.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_ingp; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_ingp + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Ingp extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_ingp"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Pah_Ingp() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 8 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9117"); + + response = test.fetch("17"); + result &= response.checkData("D0158103 01230082 0281828D 06045465" + + "78744191 0200FF"); + + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9117"); + + /*********************************************************************/ + /** Testcase 9 */ + /*********************************************************************/ + response = test.fetch("17"); + result &= response.checkData("D0158103 01230082 0281828D 06045465" + + "78744291 0210FF"); + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9117"); + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + response = test.fetch("17"); + result &= response.checkData("D0158103 01230082 0281828D 06045465" + + "78744391 02FFFF"); + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9117"); + + /*********************************************************************/ + /** Testcase 11 */ + /*********************************************************************/ + response = test.fetch("17"); + result &= response.checkData("D0158103 01230082 0281828D 06045465" + + "78744491 020000"); + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9117"); + + /*********************************************************************/ + /** Testcase 12 */ + /*********************************************************************/ + response = test.fetch("17"); + result &= response.checkData("D0158103 01238182 0281828D 06045465" + + "78744591 020010"); + response = test.terminalResponse("81030123 81020282 81030100 0D020441"); + result &= response.checkSw("9117"); + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + response = test.fetch("17"); + result &= response.checkData("D0158103 01230082 0281828D 06005465" + + "78744691 021010"); + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9117"); + + /*********************************************************************/ + /** Testcase 14 */ + /*********************************************************************/ + response = test.fetch("17"); + result &= response.checkData("D0158103 01230082 0281828D 06085465" + + "78744791 0200FF"); + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 15 */ + /*********************************************************************/ + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01230082 0281828D 0B045465" + + "78744854 65787448 91020010"); + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9111"); + + /*********************************************************************/ + /** Testcase 16 */ + /*********************************************************************/ + response = test.fetch("11"); + result &= response.checkData("D00F8103 01230082 0281828D 00910200" + + "10"); + + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9191"); + + /*********************************************************************/ + /** Testcase 17,18 */ + /*********************************************************************/ + response = test.fetch("91"); + result &= response.checkData("D0818E81 03012300 82028182 8D7F0455" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55910200" + + "10"); + + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9193"); + + /*********************************************************************/ + /** Testcase 19 */ + /*********************************************************************/ + response = test.fetch("93"); + result &= response.checkData("D0819081 03012300 82028182 8D818004" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555591" + + "020010"); + + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9100"); + + /*********************************************************************/ + /** Testcase 20,21,22 */ + /*********************************************************************/ + response = test.fetch("00"); + result &= response.checkData("D081FD81 03012300 82028182 8D81ED04" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 91020010"); + + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "16CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..8da6f55d9493bcb9c4fdd75d229f3689999c6ac2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_ingp.Api_2_Pah_Ingp_1 +uicc.test.toolkit.api_2_pah_ingp +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/javacard/api_2_pah_ingp.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/javacard/api_2_pah_ingp.cap new file mode 100644 index 0000000000000000000000000000000000000000..ee7c83c859636b9a29588c3a5ec70ba91986c218 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_ingp/javacard/api_2_pah_ingp.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/Api_2_Pah_Init_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/Api_2_Pah_Init_1.java new file mode 100644 index 0000000000000000000000000000000000000000..23450c58575011a9d3a01b3ae31c26d8cc913122 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/Api_2_Pah_Init_1.java @@ -0,0 +1,217 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Init_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_init; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_init + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Init_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Init_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Init_1 thisApplet = new Api_2_Pah_Init_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + + // Temporary buffers + byte[] source = new byte[9] ; + byte[] destination = new byte[9] ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Prepare source buffer for compare + source[0] = (byte) 0x81 ; // Command Details tag + source[1] = (byte) 0x03 ; // Length + source[2] = (byte) 0x00 ; // Command Number + source[5] = (byte) 0x82 ; // Device Identities tag + source[6] = (byte) 0x02 ; // Length + source[7] = (byte) 0x81 ; // Source device identities + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : + // Call the init() method + // Verify each simple TLV + + testCaseNb = (byte) 1 ; + + try { + // Call to init method + // type = 01h + // qualifier = 02h + // dstDevice = 03h + + proHdlr.init((byte)0x01, (byte)0x02, (byte) 0x03) ; + + // Verify length of the handler (=9) + bRes = (proHdlr.getLength() == (short)9) ; + + // Copy the handler in a buffer + proHdlr.copy(destination, (short)0, (short)9) ; + + // Delete Command Number (tested in test #2) + destination[2] = 0 ; + + // Prepare source buffer + source[3] = (byte) 0x01 ; // Type of command + source[4] = (byte) 0x02 ; // Command qualifier + source[8] = (byte) 0x03 ; // Destination device identities + + // Compare buffers + bRes = bRes & (javacard.framework.Util.arrayCompare(source, + (short)0, + destination, + (short)0, + (short)9) == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : + // Verify the command number value + + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Get command Number + proHdlr.copy(destination, (short)0, (short)3) ; + + short commandNumber = (short) (destination[2] & (short)0xFF) ; + + bRes = ((commandNumber>=(short)0x01) && (commandNumber<=(short)0xFE)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : + // Call the init() method + // Verify each simple TLV + + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + // Call to init method + // type = FFh + // qualifier = FEh + // dstDevice = FDh + + proHdlr.init((byte)0xFF, (byte)0xFE, (byte) 0xFD) ; + + // Verify length of the handler (=9) + bRes = (proHdlr.getLength() == (short)9) ; + + // Copy the handler in a buffer + proHdlr.copy(destination, (short)0, (short)9) ; + + // Delete Command Number (tested in test #2) + destination[2] = 0 ; + + // Prepare source buffer + source[3] = (byte) 0xFF ; // Type of command + source[4] = (byte) 0xFE ; // Command qualifier + source[8] = (byte) 0xFD ; // Destination device identities + + // Compare buffers + bRes = bRes & (javacard.framework.Util.arrayCompare(source, + (short)0, + destination, + (short)0, + (short)9) == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : + // Verify there is no selected TLV + + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Select 1st TLV + proHdlr.findTLV((byte)0x01, (byte)0x01) ; + + proHdlr.init((byte)0, (byte)0, (byte)0) ; + + // Verify there is no selected TLV + try { + proHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/Test_Api_2_Pah_Init.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/Test_Api_2_Pah_Init.java new file mode 100644 index 0000000000000000000000000000000000000000..e71816f6411075910e9c8a123e54a1ed7955c71b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/Test_Api_2_Pah_Init.java @@ -0,0 +1,112 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Init.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_init; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_init + * + * @version 0.0.1 - 13 juin 2005 + * @author 3GPP T3 SWG API + */ +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.Api_2_Enh_Gvsh + * + * @version 0.0.1 - 3 nov. 2004 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Init extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_init"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Pah_Init() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 4 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + test.unrecognizedEnvelope(); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "04CCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..54641a6166d620783551ae725168a1bb79978eb6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_init.Api_2_Pah_Init_1 +uicc.test.toolkit.api_2_pah_init +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/javacard/api_2_pah_init.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/javacard/api_2_pah_init.cap new file mode 100644 index 0000000000000000000000000000000000000000..67926de83095157a8cca0296ebe79669288961d8 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_init/javacard/api_2_pah_init.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/Api_2_Pah_Inmt_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/Api_2_Pah_Inmt_1.java new file mode 100644 index 0000000000000000000000000000000000000000..fdc51d97d9d1f6d1179fd2249bedf15731c12e45 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/Api_2_Pah_Inmt_1.java @@ -0,0 +1,116 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Inmt_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_inmt; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_inmt + * + * @version 0.0.1 - 22 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Inmt_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Inmt_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Inmt_1 thisApplet = new Api_2_Pah_Inmt_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of each test + boolean bRes = false ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : + // Call the init() method + // Verify each simple TLV + + testCaseNb = (byte) 1 ; + + try { + // Call to initMoreTime() method + + proHdlr.initMoreTime(); + proHdlr.send(); + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : + // Verify there is no selected TLV + + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Select 1st TLV + proHdlr.findTLV((byte)0x01, (byte)0x01) ; + + proHdlr.initMoreTime() ; + + // Verify there is no selected TLV + try { + proHdlr.getValueLength() ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } catch (Exception e) { + bRes = false ; + } + + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/Test_Api_2_Pah_Inmt.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/Test_Api_2_Pah_Inmt.java new file mode 100644 index 0000000000000000000000000000000000000000..35fc93d6f25df53f02a81487153e6074b20ab5bc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/Test_Api_2_Pah_Inmt.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +//Test_APi_2_Pah_Inmt.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_inmt; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_inmt + * + * @version 0.0.1 - 22 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Inmt extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_inmt"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Pah_Inmt() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 & 2 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + test.unrecognizedEnvelope(); + // Fetch the initMoreTime proactive command + response = test.fetch("0B"); + result = response.checkData("D0098103 01020082 028182"); + + response = test.terminalResponse("81030102 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "02CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3f3a73e7a58dcf3d5412e6c59baa425bd69c4149 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_inmt.Api_2_Pah_Inmt_1 +uicc.test.toolkit.api_2_pah_inmt +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/javacard/api_2_pah_inmt.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/javacard/api_2_pah_inmt.cap new file mode 100644 index 0000000000000000000000000000000000000000..6473b82f7b293a86d9add11863243a3f18a357c1 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_inmt/javacard/api_2_pah_inmt.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/Api_2_Pah_Send_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/Api_2_Pah_Send_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5011eaae2eb391ebebba64e45af24514bc8f139e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/Api_2_Pah_Send_1.java @@ -0,0 +1,418 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Send_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_send; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_send + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Pah_Send_1 extends TestToolkitApplet +{ + private byte[] text = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + private byte[] LONGTEXT = new byte[256] ; + + private byte[] source = {(byte)0x81, (byte)0x03, (byte)0x01, (byte)0x21, (byte)0x00, + (byte)0x82, (byte)0x02, (byte)0x81, (byte)0x02, + (byte)0x8D, (byte)0x05, (byte)0x04, (byte)'T', (byte)'e', (byte)'x', (byte)'t'} ; + + private byte[] destination = new byte[16] ; + private byte DCS_8_BIT_DATA = (byte) 0x04; + /** + * This boolean is used to know there is no invocation of select() or deselect() method by the + * send() method. + */ + + private boolean testingSelectDeselect = false ; + + /** + * Used to know there has been an invocation of select() or deselect() method. + */ + + private boolean selectDeselectCalled = false ; + + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Pah_Send_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Pah_Send_1 thisApplet = new Api_2_Pah_Send_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of send() + byte result ; + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // -------------------------------------------- + // Test Case 1 : Build a DISPLAY TEXT command + testCaseNb = (byte) 1 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 2 : send the command and verify the result + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + result = proHdlr.send() ; + + // RES_CMD_PERF = 00 (Command performed successfully) + bRes = (result == RES_CMD_PERF) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : Build a DISPLAY TEXT command + testCaseNb = (byte) 3 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 4 : send the command and verify the result + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + result = proHdlr.send() ; + + // RES_CMD_PERF_PARTIAL_COMPR = 01 (Partial comprehension) + bRes = (result == RES_CMD_PERF_PARTIAL_COMPR) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : Build a DISPLAY TEXT command + testCaseNb = (byte) 5 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 6 : send the command and verify the result + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + result = proHdlr.send() ; + + // RES_CMD_PERF_PARTIAL_COMPR = 01 (Partial comprehension) + bRes = (result == RES_CMD_PERF_PARTIAL_COMPR) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Build a DISPLAY TEXT command + testCaseNb = (byte) 7 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + reportTestOutcome(testCaseNb,true) ; + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + // -------------------------------------------- + // Test Case 8 : send the command and verify the result + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + result = proHdlr.send() ; + + // RES_CMD_PERF_MISSING_INFO = 02 + bRes = (result == RES_CMD_PERF_MISSING_INFO) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // Initialize the long text array + for (short i=0; i<(short)LONGTEXT.length; i++) { + LONGTEXT[i] = (byte)'U' ; + } + + + // -------------------------------------------- + // Test Case 9 : send a 7Fh byte command + testCaseNb = (byte) 9 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x0073) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + + // -------------------------------------------- + // Test Case 10 : send a 80h byte command + testCaseNb = (byte) 10 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)0x0074) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + + // -------------------------------------------- + // Test Case 11 : send a FDh byte command (Status 9100h) + testCaseNb = (byte) 11 ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, LONGTEXT, (short)0, (short)240) ; + proHdlr.send() ; + reportTestOutcome(testCaseNb,true) ; + + } catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + + // -------------------------------------------- + // Test Case 12 : Verify ProactiveHandler was not modified + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + // Copy the content of the handler + proHdlr.copy(source, (short)0, (short)16) ; + + // Build and send a DISPLAY TEXT command + proHdlr.send() ; + + // Copy the content of the handler + proHdlr.copy(destination, (short)0, (short)16) ; + + // Compare the content of handler + result = javacard.framework.Util.arrayCompare(source, (short)0, destination, (short)0, (short)16) ; + + bRes = (result == (byte)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Verify there is no invocation of select() or deselect() method. + + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + // Build a DISPLAY TEXT command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + selectDeselectCalled = false ; + + // Initialize a boolean + testingSelectDeselect = true ; + + // Send the command + proHdlr.send() ; + + testingSelectDeselect = false ; + + if (selectDeselectCalled) { + + reportTestOutcome(testCaseNb,false) ; + } else { + + reportTestOutcome(testCaseNb,true) ; + } + } + catch (Exception e) { + reportTestOutcome(testCaseNb,false) ; + } + + + // -------------------------------------------- + // Test Case 14 : Send a command. Terminal Response with 2 Result TLV + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + result = proHdlr.send() ; + + bRes = (result == (short) 0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Terminal Response without Result Simple TLV + // testCaseNb = (byte) 16 ; + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + + // Build and send a command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + try { + proHdlr.send() ; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Terminal Response without general result byte in Result Simple TLV + // testCaseNb = (byte) 17 ; + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + + // Build and send a command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, text, (short)0, (short)text.length) ; + + try { + proHdlr.send() ; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + } + + /** + * This implementation of deselect() method is used to test there is no invocation + * by the send() method. + */ + public void deselect() { + + if (testingSelectDeselect) { + selectDeselectCalled = true ; + } + } + + /** + * This implementation of select() method is used to test there is no invocation + * by the send() method. + * If we are not testing this specific point, we call the super method. + */ + public boolean select() { + + if (testingSelectDeselect) { + selectDeselectCalled = true ; + return true ; + } + return super.select() ; + } + +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/Test_Api_2_Pah_Send.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/Test_Api_2_Pah_Send.java new file mode 100644 index 0000000000000000000000000000000000000000..602d07271ae2a4030bbb59742f01020da46b9c47 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/Test_Api_2_Pah_Send.java @@ -0,0 +1,249 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Pah_Send.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_pah_send; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_pah_send + * + * @version 0.0.1 - 14 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Pah_Send extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_pah_send"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Pah_Send() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1,2 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 3,4 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030101"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 5,6 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030201 55"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 7,8 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030402 654321"); + result &= response.checkSw("9181"); + + /*********************************************************************/ + /** Testcase 9 */ + /*********************************************************************/ + response = test.fetch("81"); + result &= response.checkData("D07F8103 01210082 0281028D 74045555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9183"); + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + response = test.fetch("83"); + result &= response.checkData("D0818081 03012100 82028102 8D750455" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "555555"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9100"); + + /*********************************************************************/ + /** Testcase 11 */ + /*********************************************************************/ + response = test.fetch("00"); + result &= response.checkData("D081FD81 03012100 82028102 8D81F104" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 12 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 14 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030202 12030303" + + "3456"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 15 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 16 */ + /*********************************************************************/ + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 810300"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "10CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5a72d859406dab5e1990ed232c082ba9f86a0ae5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_pah_send.Api_2_Pah_Send_1 +uicc.test.toolkit.api_2_pah_send +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/javacard/api_2_pah_send.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/javacard/api_2_pah_send.cap new file mode 100644 index 0000000000000000000000000000000000000000..e057e801925189e206b75c0b5d1fd1c88bd66700 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_pah_send/javacard/api_2_pah_send.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/Api_2_Phs_Gthd_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/Api_2_Phs_Gthd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..76924328c7b4debbd14e93bdd77521260e5558b9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/Api_2_Phs_Gthd_1.java @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------------- +//Api_2_Phs_Gthd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_phs_gthd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.ProactiveHandler; +import uicc.toolkit.ProactiveHandlerSystem; + +/** + * Test Area : uicc.test.toolkit.api_2_phs_gthd + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Phs_Gthd_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + + /** + * Constructor of the applet + */ + public Api_2_Phs_Gthd_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Phs_Gthd_1 thisApplet = new Api_2_Phs_Gthd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : use th methode getTheHandler() Twice + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + ProactiveHandler ProHdlr1 = ProactiveHandlerSystem.getTheHandler(); + ProactiveHandler ProHdlr2 = ProactiveHandlerSystem.getTheHandler(); + + if (ProHdlr1==ProHdlr2 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : verify that the methode getTheHandler return ProactiveHandler reference + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + ProactiveHandler ProHdlr1 = ProactiveHandlerSystem.getTheHandler(); + + if (ProHdlr1 instanceof ProactiveHandler) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : verify that the methode getTheHandler does not return NULL + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + ProactiveHandler ProHdlr1 = ProactiveHandlerSystem.getTheHandler(); + + if (ProHdlr1!=null) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } +} + + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/Test_Api_2_Phs_Gthd.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/Test_Api_2_Phs_Gthd.java new file mode 100644 index 0000000000000000000000000000000000000000..475c4c90cfc7176dddfd80660b2dbb571b973d31 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/Test_Api_2_Phs_Gthd.java @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Phs_Gthd.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_phs_gthd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.api_2_phs_gthd + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Phs_Gthd extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_phs_gthd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Phs_Gthd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Applet installation */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 3 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test cases 1,2,3 + for (byte i = 0; i < 3; i++) + { + response = test.unrecognizedEnvelope(); + } + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "03CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ee963d15c3894d82ea401b21619a514f223d4e0f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_phs_gthd.Api_2_Phs_Gthd_1 +uicc.test.toolkit.api_2_phs_gthd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/javacard/api_2_phs_gthd.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/javacard/api_2_phs_gthd.cap new file mode 100644 index 0000000000000000000000000000000000000000..fc48192c41b4c9c613ad4f24b5808d7b36022cb4 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_phs_gthd/javacard/api_2_phs_gthd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cchd/Api_2_Prh_Cchd_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cchd/Api_2_Prh_Cchd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5eddaca440c892e1a6d6c22afaa95ccbee96ecb4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cchd/Api_2_Prh_Cchd_1.java @@ -0,0 +1,356 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Cchd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cchd; + +import javacard.framework.*; +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cchd + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Cchd_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + public final static byte CHANNEL_ID1 = (byte)0x01; + public final static byte QUALIFIER_1 = (byte)0x01; + public static byte[] ADDRESS_VALUE = {(byte)0x81, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88}; + public static byte[] BEARER_VALUE = {(byte)0x03, (byte)0x00}; + public static byte[] BUFFER_SIZE_VALUE = {(byte)0x00, (byte)0x0A}; + public static byte[] RES_BUFFER2 = {(byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o', (byte)'2'}; + public static byte[] RES_BUFFER3 = {(byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o', (byte)'3'}; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Cchd_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Cchd_1 thisApplet = new Api_2_Prh_Cchd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // destination buffer declaration + byte[] dstBuffer = new byte[8]; + short dstOffset; + short dstLength; + + // Result of each test + boolean bRes = true ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + testCaseNb = (byte) 1; + // build proactive commands OPEN CHANNEL + try { + proHdlr.init(PRO_CMD_OPEN_CHANNEL, QUALIFIER_1, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS_VALUE, (short)0, (short)5); + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_VALUE, (short)0, (short)2); + proHdlr.appendTLV(TAG_BUFFER_SIZE, BUFFER_SIZE_VALUE, (short)0, (short)2); + proHdlr.send(); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 2 : Build and send a RECEIVE DATA command + testCaseNb = (byte) 2; + try { + proHdlr.init(PRO_CMD_RECEIVE_DATA, QUALIFIER_1, DEV_ID_CHANNEL_1); + proHdlr.appendTLV(TAG_CHANNEL_DATA_LENGTH, (byte)0x02); + proHdlr.send(); + // copyChannelData() with NULL dstBuffer + dstOffset = (short) 0; + dstLength = (short) 1; + try { + (ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(null, dstOffset, dstLength); + bRes = false; + } + catch (NullPointerException e) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 3 : Build and send a RECEIVE DATA command + testCaseNb = (byte) 3; + try { + proHdlr.init(PRO_CMD_RECEIVE_DATA, QUALIFIER_1, DEV_ID_CHANNEL_1); + proHdlr.appendTLV(TAG_CHANNEL_DATA_LENGTH, (byte)0x06); + proHdlr.send(); + // copyChannelData() with negative dstOffset + dstOffset = (short) -1; + dstLength = (short) 1; + try { + (ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 3 : copyChannelData() with negative dstLength + testCaseNb = (byte) 4; + + dstOffset = (short) 0; + dstLength = (short) -1; + try { + (ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // check dstBuffer is empty + testCaseNb = (byte) 5; + bRes = true; + for (short i=0; i<(short)(dstBuffer.length-1); i++) { + if (dstBuffer[i] != (byte)0) { + bRes &= false; + } + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 4 : copyChannelData() with dstOffset+dstLength greater than dstBuffer.length + testCaseNb = (byte) 6; + + dstOffset = (short) 5; + dstLength = (short) 5; + try { + (ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength); + bRes = false; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // check dstBuffer is empty + testCaseNb = (byte) 7; + bRes = true; + for (short i=0; i<(short)(dstBuffer.length-1); i++) { + if (dstBuffer[i] != (byte)0) { + bRes &= false; + } + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 5 : copyChannelData() with dstLength too large + testCaseNb = (byte) 8; + bRes = false; + dstOffset = (short) 0; + dstLength = (short) 7; + try { + (ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength); + bRes = false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 6 : Build and send a RECEIVE DATA command + testCaseNb = (byte) 9; + bRes = false; + try { + proHdlr.init(PRO_CMD_RECEIVE_DATA, QUALIFIER_1, DEV_ID_CHANNEL_1); + proHdlr.appendTLV(TAG_CHANNEL_DATA_LENGTH, (byte)0x06); + proHdlr.send(); + // copyChannelData() without Channel Data TLV element + dstOffset = (short) 0; + dstLength = (short) 6; + try { + (ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength); + bRes = false; + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 7 : Successful copyChannelData() + // Build and send a RECEIVE DATA command + testCaseNb = (byte) 10; + try { + proHdlr.init(PRO_CMD_RECEIVE_DATA, QUALIFIER_1, DEV_ID_CHANNEL_1); + proHdlr.appendTLV(TAG_CHANNEL_DATA_LENGTH, (byte)0x06); + proHdlr.send(); + // Call findTLV() with TAG of DEVICE IDENTITY + proHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1); + // copyChannelData() + dstOffset = (short) 0; + dstLength = (short) 6; + bRes = ((ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength) == (short)(dstOffset + dstLength)); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 8 : Compare copied Buffer + testCaseNb = (byte) 11; + bRes = true; + if (Util.arrayCompare(dstBuffer, (short)0, RES_BUFFER2, (short)0, dstLength) != 0) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 9 : Check the Channel Data TLV is selected + testCaseNb = (byte) 12; + bRes = true; + if ((ProactiveResponseHandlerSystem.getTheHandler()).getValueByte((short)0) != 'H') { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 10: Successful copyChannelData() + testCaseNb = (byte) 13; + bRes = true; + dstOffset = (short) 2; + dstLength = (short) 3; + if ((ProactiveResponseHandlerSystem.getTheHandler()).copyChannelData(dstBuffer, dstOffset, dstLength) != (short)(dstOffset+dstLength)) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 11: Compare copied Buffer + testCaseNb = (byte) 14; + bRes = true; + if (Util.arrayCompare(dstBuffer, dstOffset, RES_BUFFER2, (short)0, dstLength) != 0) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------- + // Test Case 12: Successful copyChannelData() with initialized buffer + testCaseNb = (byte) 15; + for (short i=0; i dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + dstOffset = (short)6 ; + dstLength = (short)0 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + dstOffset = (short)-1 ; + dstLength = (short)1 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + dstOffset = (short)0 ; + dstLength = (short)6 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + dstOffset = (short)3 ; + dstLength = (short)3 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + dstOffset = (short)0 ; + dstLength = (short)-1 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : dstLength > length of the simple TLV list + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + try { + dstOffset = (short)0 ; + dstLength = (short)13 ; + proRespHdlr.copy(dstBuffer13, dstOffset, dstLength) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call, whole buffer + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + dstOffset = (short)0 ; + dstLength = (short)12 ; + result = proRespHdlr.copy(dstBuffer12, dstOffset, dstLength) ; + + bRes = (result == (short)(dstOffset + dstLength)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Compare the buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + // Initialise the buffer + compareBuffer[0] = (byte)0x81 ; compareBuffer[1] = (byte)0x03 ; + compareBuffer[2] = (byte)0x01 ; compareBuffer[3] = (byte)0x21 ; compareBuffer[4] = (byte)0x00 ; + compareBuffer[5] = (byte)0x02 ; compareBuffer[6] = (byte)0x02 ; + compareBuffer[7] = (byte)0x82 ; compareBuffer[8] = (byte)0x81 ; + compareBuffer[9] = (byte)0x03 ; compareBuffer[10] = (byte)0x01 ; compareBuffer[11] = (byte)0x00 ; + + // Compare buffers + result = Util.arrayCompare(compareBuffer, (short)0, + dstBuffer12, (short)0, (short)12) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successful call, part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + dstBuffer20[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + + try { + + dstOffset = (short)3 ; + dstLength = (short)12 ; + result = proRespHdlr.copy(dstBuffer20, dstOffset, dstLength) ; + + bRes = (result == (short)(dstOffset + dstLength)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Compare the buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + // Initialise the buffer + compareBuffer[3] = (byte)0x81 ; compareBuffer[4] = (byte)0x03 ; + compareBuffer[5] = (byte)0x01 ; compareBuffer[6] = (byte)0x21 ; compareBuffer[7] = (byte)0x00 ; + compareBuffer[8] = (byte)0x02 ; compareBuffer[9] = (byte)0x02 ; + compareBuffer[10] = (byte)0x82 ; compareBuffer[11] = (byte)0x81 ; + compareBuffer[12] = (byte)0x03 ; compareBuffer[13] = (byte)0x01 ; compareBuffer[14] = (byte)0x00 ; + + // Compare buffers + result = Util.arrayCompare(compareBuffer, (short)0, + dstBuffer20, (short)0, (short)20) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successful call, part of a buffer + testCaseNb = (byte)12 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + dstBuffer20[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + + try { + + dstOffset = (short)3 ; + dstLength = (short)9 ; + result = proRespHdlr.copy(dstBuffer20, dstOffset, dstLength) ; + + bRes = (result == (short)(dstOffset + dstLength)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare the buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + // Initialise the buffer + compareBuffer[3] = (byte)0x81 ; compareBuffer[4] = (byte)0x03 ; + compareBuffer[5] = (byte)0x01 ; compareBuffer[6] = (byte)0x21 ; compareBuffer[7] = (byte)0x00 ; + compareBuffer[8] = (byte)0x02 ; compareBuffer[9] = (byte)0x02 ; + compareBuffer[10] = (byte)0x82 ; compareBuffer[11] = (byte)0x81 ; + + // Compare buffers + result = Util.arrayCompare(compareBuffer, (short)0, + dstBuffer20, (short)0, (short)20) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/Test_Api_2_Prh_Copy.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/Test_Api_2_Prh_Copy.java new file mode 100644 index 0000000000000000000000000000000000000000..4fc6046d97ec88dcc871bba7922a06272ebcee02 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/Test_Api_2_Prh_Copy.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Copy.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_copy; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_copy + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Copy extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_copy"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Copy() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 13 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no additional information + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c419824fe59495e1f798e8f9d92d5c586c71668e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_copy.Api_2_Prh_Copy_1 +uicc.test.toolkit.api_2_prh_copy +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/javacard/api_2_prh_copy.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/javacard/api_2_prh_copy.cap new file mode 100644 index 0000000000000000000000000000000000000000..24a70bc5063696f93c4157a956694dac2dcc7c83 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_copy/javacard/api_2_prh_copy.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/Api_2_Prh_Cpai_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/Api_2_Prh_Cpai_1.java new file mode 100644 index 0000000000000000000000000000000000000000..d1b368cdc4959ff4d250b2c69a415a5b59350df4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/Api_2_Prh_Cpai_1.java @@ -0,0 +1,715 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Cpai_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cpai; + +import uicc.test.util.*; +import uicc.toolkit.*; +import javacard.framework.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cpai + * + * @version 0.0.1 - 22 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Cpai_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + private byte[] dstBuffer5 = new byte[5] ; + private byte[] dstBuffer6 = new byte[6] ; + private byte[] dstBuffer7 = new byte[7] ; + private byte[] dstBuffer9 = new byte[9] ; + private byte[] dstBuffer10 = new byte[10] ; + private byte[] dstBuffer20 = new byte[20] ; + private byte[] dstBufferF2 = new byte[0xF2] ; + + private byte[] src = new byte[256] ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Cpai_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Cpai_1 thisApplet = new Api_2_Prh_Cpai_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + ProactiveResponseHandler proRespHdlr = null ; + + short result = (short) 0 ; + + // -------------------------------------------- + // Test Case 1 : NULL as parameter to dstBuffer + + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + // copyAdditionalInformation() with null buffer + proRespHdlr.copyAdditionalInformation(null, (short)0, (short)1) ; + + } catch (NullPointerException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : dstOffset > dstBuffer.length + + testCaseNb = (byte) 2 ; + bRes = false ; + try { + proRespHdlr.copyAdditionalInformation(dstBuffer10, (short)11, (short)0) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + proRespHdlr.copyAdditionalInformation(dstBuffer10, (short)-1, (short)1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + proRespHdlr.copyAdditionalInformation(dstBuffer10, (short)0, (short)11) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + proRespHdlr.copyAdditionalInformation(dstBuffer10, (short)6, (short)5) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + proRespHdlr.copyAdditionalInformation(dstBuffer10, (short)6, (short)-1) ; + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successfull call, dstBuffer is the whole buffer + + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Successfull call, dstBuffer is the whole buffer + result = proRespHdlr.copyAdditionalInformation(dstBuffer5, (short)0, (short)5) ; + + // Verify the result + bRes = (result == (short)5) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Compare dstBuffer + + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + // Response from the mobile + src[0] = (byte) 0x01 ; + src[1] = (byte) 0x23 ; + src[2] = (byte) 0x45 ; + src[3] = (byte) 0x67 ; + src[4] = (byte) 0x89 ; + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBuffer5, (short)0, (short)5) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Verify the selected TLV + + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + // Verify the TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short) 0x06) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call, dstBuffer is part of a buffer + + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Successfull call, dstBuffer is the whole buffer + result = proRespHdlr.copyAdditionalInformation(dstBuffer7, (short)2, (short)5) ; + + // Verify the result + bRes = (result == (short)7) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Compare dstBuffer + + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + // Response from the mobile + src[0] = (byte) 0xAB ; + src[1] = (byte) 0xCD ; + src[2] = (byte) 0xEF ; + src[3] = (byte) 0xFE ; + src[4] = (byte) 0xDC ; + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBuffer7, (short)2, (short)5) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call, dstBuffer is part of a buffer + + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Successfull call, dstBuffer is the whole buffer + result = proRespHdlr.copyAdditionalInformation(dstBuffer7, (short)0, (short)5) ; + + // Verify the result + bRes = (result == (short)5) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare dstBuffer + + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Response from the mobile + src[0] = (byte) 0xFE ; + src[1] = (byte) 0xDC ; + src[2] = (byte) 0xBA ; + src[3] = (byte) 0x98 ; + src[4] = (byte) 0x76 ; + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBuffer7, (short)0, (short)5) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successfull call, dstBuffer is part of a buffer + + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Successfull call, dstBuffer is the whole buffer + result = proRespHdlr.copyAdditionalInformation(dstBuffer9, (short)2, (short)5) ; + + // Verify the result + bRes = (result == (short)7) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Compare dstBuffer + + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + + // Response from the mobile + src[0] = (byte) 0x00 ; + src[1] = (byte) 0x11 ; + src[2] = (byte) 0x22 ; + src[3] = (byte) 0x33 ; + src[4] = (byte) 0x44 ; + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBuffer9, (short)2, (short)5) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successfull call, F2h bytes in the response + + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Successfull call, dstBuffer is the whole buffer + result = proRespHdlr.copyAdditionalInformation(dstBufferF2, (short)0, (short)0xF2) ; + + // Verify the result + bRes = (result == (short)0xF2) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Compare dstBuffer + + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + + // Response from the mobile + for (short i=(short)0; i<(short)dstBufferF2.length; i++) { + src[i] = (byte)i ; + } + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBufferF2, (short)0, (short)0xF2) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Verify the selected TLV + + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + + // Verify the TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short) 0xF3) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 19 : dstLength > data available + + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response (5 additional bytes) + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // dstLength > data available ==> ToolkitException.OUT_OF_TLV_BOUNDARIES + proRespHdlr.copyAdditionalInformation(dstBuffer6, (short)0, (short)6) ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true ; + } + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 20 : Verify whole dstBuffer + + testCaseNb = (byte) 20 ; + bRes = false ; + + try { + + // Initialise dstBuffer + for (short i=(short)0; i<(short)dstBuffer20.length; i++) { + dstBuffer20[i] = (byte)i ; + } + + // Response from the mobile + for (short i=(short)0; i<(short)dstBuffer20.length; i++) { + src[i] = (byte)i ; + } + + src[5] = (byte) 0x00 ; + src[6] = (byte) 0x11 ; + src[7] = (byte) 0x22 ; + src[8] = (byte) 0x33 ; + src[9] = (byte) 0x44 ; + + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Successfull call + proRespHdlr.copyAdditionalInformation(dstBuffer20, (short)5, (short)5) ; + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBuffer20, (short)0, (short)20) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 21 : Successfull call, Terminal Response with 2 Result TLV + + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Clear the buffer + for (short i=0; i<(short)5; i++) { + dstBuffer5[i] = 0 ; + } + + result = proRespHdlr.copyAdditionalInformation(dstBuffer5, (short)0, (short)5) ; + + // Verify the result + bRes = (result == (short)5) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 22 : Compare dstBuffer + + testCaseNb = (byte) 22 ; + bRes = false ; + + try { + + // Response from the mobile + src[0] = (byte) 0x01 ; + src[1] = (byte) 0x23 ; + src[2] = (byte) 0x45 ; + src[3] = (byte) 0x67 ; + src[4] = (byte) 0x89 ; + + // Compare the buffer + result = Util.arrayCompare(src, (short)0, dstBuffer5, (short)0, (short)5) ; + + bRes = (result == (short) 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 23 : Verify the selected TLV + + testCaseNb = (byte) 23 ; + bRes = false ; + + try { + + // Verify the TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short) 0x06) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 24 : No Result TLV in Response + + testCaseNb = (byte) 24 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // An exception is thrown by send() as there is no General Result TLV + try { + proHdlr.send() ; + } + catch (Exception e) { + } + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + result = proRespHdlr.copyAdditionalInformation(dstBuffer5, (short)0, (short)1) ; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/Test_Api_2_Prh_Cpai.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/Test_Api_2_Prh_Cpai.java new file mode 100644 index 0000000000000000000000000000000000000000..2ca0e89971f82ee16cb6c33faf5ebc7defd963db --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/Test_Api_2_Prh_Cpai.java @@ -0,0 +1,251 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Cpai.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cpai; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cpai + * + * @version 0.0.1 - 22 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Cpai extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_cpai"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Cpai() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 6 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + // Terminal response with 11 additional bytes + response = test.terminalResponse("81030121 00020282 81030C01 01234567" + + "89ABCDEF 012345"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 7 to 9 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 5 additional bytes + response = test.terminalResponse("81030121 00020282 81030601 01234567" + + "89"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 10 & 11 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 6 additional bytes + response = test.terminalResponse("81030121 00020282 81030701 ABCDEFFE" + + "DCBA"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 12 & 13 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 7 additional bytes + response = test.terminalResponse("81030121 00020282 81030801 FEDCBA98" + + "765432"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 14 & 15 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 8 additional bytes + response = test.terminalResponse("81030121 00020282 81030901 00112233" + + "44556677"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 16 to 18 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with F2 additional bytes + response = test.terminalResponse("81030121 00020282 810381F3 01000102" + + "03040506 0708090A 0B0C0D0E 0F101112" + + "13141516 1718191A 1B1C1D1E 1F202122" + + "23242526 2728292A 2B2C2D2E 2F303132" + + "33343536 3738393A 3B3C3D3E 3F404142" + + "43444546 4748494A 4B4C4D4E 4F505152" + + "53545556 5758595A 5B5C5D5E 5F606162" + + "63646566 6768696A 6B6C6D6E 6F707172" + + "73747576 7778797A 7B7C7D7E 7F808182" + + "83848586 8788898A 8B8C8D8E 8F909192" + + "93949596 9798999A 9B9C9D9E 9FA0A1A2" + + "A3A4A5A6 A7A8A9AA ABACADAE AFB0B1B2" + + "B3B4B5B6 B7B8B9BA BBBCBDBE BFC0C1C2" + + "C3C4C5C6 C7C8C9CA CBCCCDCE CFD0D1D2" + + "D3D4D5D6 D7D8D9DA DBDCDDDE DFE0E1E2" + + "E3E4E5E6 E7E8E9EA EBECEDEE EFF0F1"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 19 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 5 additional bytes + response = test.terminalResponse("81030121 00020282 81030601 00112233" + + "44"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 20 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 5 additional bytes + response = test.terminalResponse("81030121 00020282 81030601 00112233" + + "44"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 21 to 23 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 2 results TLV + response = test.terminalResponse("81030121 00020282 81030601 01234567" + + "89030100"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 24 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no result TLV + response = test.terminalResponse("81030121 00020282 81"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "18CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..785b92b9b9cdcd5c5e09e20fdbdb43376c791b14 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_cpai.Api_2_Prh_Cpai_1 +uicc.test.toolkit.api_2_prh_cpai +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/javacard/api_2_prh_cpai.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/javacard/api_2_prh_cpai.cap new file mode 100644 index 0000000000000000000000000000000000000000..1db5b136c628d3c9176a8a86f1822ecf57c7af26 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpai/javacard/api_2_prh_cpai.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cprv/Api_2_Prh_Cprv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cprv/Api_2_Prh_Cprv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b84fcf699dab2596ded8f0adf130e239094effe8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cprv/Api_2_Prh_Cprv_1.java @@ -0,0 +1,540 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Cprv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cprv; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cprv + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Cprv_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + private byte[] compareBuffer5 = new byte[5] ; + private byte[] compareBuffer15 = new byte[15] ; + private byte[] compareBuffer17 = new byte[17] ; + private byte[] compareBuffer20 = new byte[20] ; + + public final byte DCS_8_BIT_DATA = (byte)0x04; + /** + * Constructor of the applet + */ + public Api_2_Prh_Cprv_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Cprv_1 thisApplet = new Api_2_Prh_Cprv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + ProactiveResponseHandler proRespHdlr = null ; + + // Result of method + short result = 0 ; + + short valueOffset = 0 ; + short compareOffset = 0 ; + short compareLength = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null as compareBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Select Text String TLV + proRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + try { + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + proRespHdlr.compareValue(valueOffset, null, compareOffset, compareLength) ; + + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : compareOffset >= compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + valueOffset = (short)0 ; + compareOffset = (short)6 ; + compareLength = (short)0 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + valueOffset = (short)0 ; + compareOffset = (short)-1 ; + compareLength = (short)1 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareLength > compareBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + compareLength > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + valueOffset = (short)0 ; + compareOffset = (short)3 ; + compareLength = (short)3 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compareLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)-1 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + valueOffset = (short)7 ; + compareOffset = (short)0 ; + compareLength = (short)0 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + valueOffset = (short)-1 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : compareLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)7 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + compareLength > Text String length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + valueOffset = (short)2 ; + compareOffset = (short)0 ; + compareLength = (short)5 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable element + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proRespHdlr.compareValue(valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i dstBuffer.length + + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Build and send a GET INPUT command + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // CopyTextString() with a dstOffset + text length > dstBuffer.length + proRespHdlr.copyTextString(ARRAY04, (short)2) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + // CopyTextString() with dstOffset < 0 + proRespHdlr.copyTextString(ARRAY04, (short)-1) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + + + // -------------------------------------------- + // Test Case 4 : unavailable Text String TLV + + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Build and send a DISPLAY TEXT command + proHdlr.initDisplayText((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + proRespHdlr.copyTextString(ARRAY04, (short)0) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : successfull call with null Text String TLV + + testCaseNb = (byte) 5 ; + bRes = false ; + + // Initialise dstBuffer and src + dstBuffer = ARRAY04 ; + + for (short i=0; i<4; i++) { + dstBuffer[i] = (byte)(i+0xF0) ; + src[i] = (byte)(i+0xF0) ; + } + + try { + + // Build and send a GET INPUT command + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)02) ; + + bRes = (result == (short)2) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compare buffer + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)4) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + + // -------------------------------------------- + // Test Case 7 : successfull call with text length = 1 + + testCaseNb = (byte) 7 ; + bRes = false ; + + // Initialise dstBuffer + dstBuffer = ARRAY04 ; + + for (short i=0; i<4; i++) { + dstBuffer[i] = (byte)i ; + } + + try { + + // Build and send a GET INPUT command + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)00) ; + + bRes = (result == (short)1) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : compare buffer + + // Initialise src + src[0] = (byte) 0x41 ; + for (short i=1; i<4; i++) { + src[i] = (byte)i ; + } + + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)4) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : successfull call with text length = 2 + + testCaseNb = (byte) 9 ; + bRes = false ; + + // Initialise dstBuffer + dstBuffer = ARRAY04 ; + + for (short i=0; i<4; i++) { + dstBuffer[i] = (byte)i ; + } + + try { + + // Build and send a GET INPUT command + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)2) ; + + bRes = (result == (short)4) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : compare buffer + + // Initialise src + src[2] = (byte) 0x42 ; + src[3] = (byte) 0x43 ; + for (short i=0; i<2; i++) { + src[i] = (byte)i ; + } + + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)4) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : verify the TLV selected + + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x03) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : successfull call with text length = 7Eh + + testCaseNb = (byte) 12 ; + bRes = false ; + + // Initialise dstBuffer + dstBuffer = ARRAY7E ; + + for (short i=0; i<(short)0x7E; i++) { + dstBuffer[i] = 0 ; + } + + try { + + // Build and send a GET INPUT command + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)0) ; + + bRes = (result == (short)0x7E) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : compare buffer + + // Initialise src + for (short i=0; i<(short)0x7E; i++) { + src[i] = (byte)(i+1) ; + } + + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)0x7E) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : verify the TLV selected + + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x7F) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : successfull call with text length = 7Fh + + testCaseNb = (byte) 15 ; + bRes = false ; + + // Initialise dstBuffer + dstBuffer = ARRAYFF ; + + for (short i=0; i<(short)0xFF; i++) { + dstBuffer[i] = (byte)i ; + } + + try { + + // Build and send a GET INPUT command. + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)0x10) ; + + bRes = (result == (short)0x8F) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : compare buffer + + // Initialise src + for (short i=0; i<(short)0xFF; i++) { + src[i] = (byte)i ; + } + + for (short i=1; i<(short)0x80; i++) { + src[(short)(i+0x0F)] = (byte)i; + } + + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)0xFF) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : successfull call with text length = EFh + + testCaseNb = (byte) 17 ; + bRes = false ; + + // Initialise dstBuffer + dstBuffer = ARRAYFF ; + + for (short i=0; i<(short)0xFF; i++) { + dstBuffer[i] = 0 ; + } + + try { + + // Build and send a GET INPUT command. + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)0) ; + + bRes = (result == (short)0xEF) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : compare buffer + + // Initialise src + for (short i=0; i<(short)0xFF; i++) { + src[i] = 0 ; + } + for (short i=0; i<(short)0xEF; i++) { + src[i] = (byte)(i+1) ; + } + + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)0xFF) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // --------------------------------------------------------------------------- + // Test Case 19 : successfull call with text length = 2 and 2 text string TLV + + testCaseNb = (byte) 19 ; + bRes = false ; + + // Initialise dstBuffer + dstBuffer = ARRAY04 ; + + for (short i=0; i<4; i++) { + dstBuffer[i] = (byte)i ; + } + + try { + + // Build and send a GET INPUT command + proHdlr.initGetInput((byte)0, (byte)4, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + proHdlr.send() ; + + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Copy text string + result = proRespHdlr.copyTextString(dstBuffer, (short)2) ; + + bRes = (result == (short)4) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 20 : compare buffer + + // Initialise src + src[2] = (byte) 0x42 ; + src[3] = (byte) 0x43 ; + for (short i=0; i<2; i++) { + src[i] = (byte)i ; + } + + testCaseNb = (byte) 20 ; + bRes = false ; + + try { + + result = Util.arrayCompare(src, (short)0, dstBuffer, (short)0, (short)4) ; + + bRes = (result == 0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 21 : verify the TLV selected + + testCaseNb = (byte) 21 ; + bRes = false ; + + try { + + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x03) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/Test_Api_2_Prh_Cpts.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/Test_Api_2_Prh_Cpts.java new file mode 100644 index 0000000000000000000000000000000000000000..2b8e331f5ce01bfb5e4978e1d1eecee4f8598d4e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/Test_Api_2_Prh_Cpts.java @@ -0,0 +1,253 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Cpts.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cpts; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cpts + * + * @version 0.0.1 - 23 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Cpts extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_cpts"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Cpts() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9116"); + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 2 & 3 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + response = test.terminalResponse("81030123 00020282 81030100 0D040441" + + "4243"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Fetch the display text proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 5 & 6 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + response = test.terminalResponse("81030123 00020282 81030100 0D00"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 7 & 8 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal response with Text String Length = 01h + response = test.terminalResponse("81030123 00020282 81030100 0D020041"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 9 to 11 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal response with Text String Length = 02h + response = test.terminalResponse("81030123 00020282 81030100 0D030042" + + "43"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 12 to 14 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal response with Text String Length = 7Eh + response = test.terminalResponse("81030123 00020282 81030100 0D7F0401" + + "02030405 06070809 0A0B0C0D 0E0F1011" + + "12131415 16171819 1A1B1C1D 1E1F2021" + + "22232425 26272829 2A2B2C2D 2E2F3031" + + "32333435 36373839 3A3B3C3D 3E3F4041" + + "42434445 46474849 4A4B4C4D 4E4F5051" + + "52535455 56575859 5A5B5C5D 5E5F6061" + + "62636465 66676869 6A6B6C6D 6E6F7071" + + "72737475 76777879 7A7B7C7D 7E"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 15 to 16 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal response with Text String Length = 7Fh + response = test.terminalResponse("81030123 00020282 81030100 0D818004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 17 to 18 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal response with Text String Length = EFh + response = test.terminalResponse("81030123 00020282 81030100 0D81F004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0" + + "D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0" + + "E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEF"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 19 to 21 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal response with 2 Text String TLV + response = test.terminalResponse("81030123 00020282 81030100 0D030042" + + "430D0204 44"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "15CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b3d145d670b28490a167f4efbca6d7195a0b8a91 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_cpts.Api_2_Prh_Cpts_1 +uicc.test.toolkit.api_2_prh_cpts +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/javacard/api_2_prh_cpts.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/javacard/api_2_prh_cpts.cap new file mode 100644 index 0000000000000000000000000000000000000000..e60f9154629be08da83215af455f8aa4d16c6681 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpts/javacard/api_2_prh_cpts.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/Api_2_Prh_Cpyv_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/Api_2_Prh_Cpyv_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f61be099bce19a6e957c35491e13c16c803dcded --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/Api_2_Prh_Cpyv_1.java @@ -0,0 +1,378 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Cpyv_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cpyv; + +import uicc.test.util.*; +import uicc.toolkit.*; +import javacard.framework.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cpyv + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Cpyv_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + private byte[] dstBuffer5 = new byte[5] ; + private byte[] dstBuffer13 = new byte[13] ; + private byte[] dstBuffer12 = new byte[12] ; + private byte[] dstBuffer20 = new byte[20] ; + private byte[] compareBuffer = new byte[20] ; + + public final byte DCS_8_BIT_DATA = (byte)0x04; + /** + * Constructor of the applet + */ + public Api_2_Prh_Cpyv_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Cpyv_1 thisApplet = new Api_2_Prh_Cpyv_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // Response handler + ProactiveResponseHandler proRespHdlr = null; + + short dstOffset = (short)0 ; + short dstLength = (short)0 ; + + short result = 0 ; + + // -------------------------------------------- + // Test Case 1 : Build and send a PRO command / NULL buffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Null as dstBuffer + try { + dstOffset = (short)0 ; + dstLength = (short)1 ; + proRespHdlr.copy(null, dstOffset, dstLength) ; + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : dstOffset > dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + dstOffset = (short)6 ; + dstLength = (short)0 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + dstOffset = (short)-1 ; + dstLength = (short)1 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBuffer.length + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + dstOffset = (short)0 ; + dstLength = (short)6 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + dstOffset = (short)3 ; + dstLength = (short)3 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + try { + dstOffset = (short)0 ; + dstLength = (short)-1 ; + proRespHdlr.copy(dstBuffer5, dstOffset, dstLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : dstLength > length of the simple TLV list + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + try { + dstOffset = (short)0 ; + dstLength = (short)13 ; + proRespHdlr.copy(dstBuffer13, dstOffset, dstLength) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call, whole buffer + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + dstOffset = (short)0 ; + dstLength = (short)12 ; + result = proRespHdlr.copy(dstBuffer12, dstOffset, dstLength) ; + + bRes = (result == (short)(dstOffset + dstLength)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Compare the buffer + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + // Initialise the buffer + compareBuffer[0] = (byte)0x81 ; compareBuffer[1] = (byte)0x03 ; + compareBuffer[2] = (byte)0x01 ; compareBuffer[3] = (byte)0x21 ; compareBuffer[4] = (byte)0x00 ; + compareBuffer[5] = (byte)0x02 ; compareBuffer[6] = (byte)0x02 ; + compareBuffer[7] = (byte)0x82 ; compareBuffer[8] = (byte)0x81 ; + compareBuffer[9] = (byte)0x03 ; compareBuffer[10] = (byte)0x01 ; compareBuffer[11] = (byte)0x00 ; + + // Compare buffers + result = Util.arrayCompare(compareBuffer, (short)0, + dstBuffer12, (short)0, (short)12) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successful call, part of a buffer + testCaseNb = (byte) 10 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + dstBuffer20[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + + try { + + dstOffset = (short)3 ; + dstLength = (short)12 ; + result = proRespHdlr.copy(dstBuffer20, dstOffset, dstLength) ; + + bRes = (result == (short)(dstOffset + dstLength)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Compare the buffer + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + // Initialise the buffer + compareBuffer[3] = (byte)0x81 ; compareBuffer[4] = (byte)0x03 ; + compareBuffer[5] = (byte)0x01 ; compareBuffer[6] = (byte)0x21 ; compareBuffer[7] = (byte)0x00 ; + compareBuffer[8] = (byte)0x02 ; compareBuffer[9] = (byte)0x02 ; + compareBuffer[10] = (byte)0x82 ; compareBuffer[11] = (byte)0x81 ; + compareBuffer[12] = (byte)0x03 ; compareBuffer[13] = (byte)0x01 ; compareBuffer[14] = (byte)0x00 ; + + // Compare buffers + result = Util.arrayCompare(compareBuffer, (short)0, + dstBuffer20, (short)0, (short)20) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successful call, part of a buffer + testCaseNb = (byte)12 ; + bRes = false ; + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + dstBuffer20[i] = (byte)i ; + compareBuffer[i] = (byte)i ; + } + + try { + + dstOffset = (short)3 ; + dstLength = (short)9 ; + result = proRespHdlr.copy(dstBuffer20, dstOffset, dstLength) ; + + bRes = (result == (short)(dstOffset + dstLength)) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare the buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + // Initialise the buffer + compareBuffer[3] = (byte)0x81 ; compareBuffer[4] = (byte)0x03 ; + compareBuffer[5] = (byte)0x01 ; compareBuffer[6] = (byte)0x21 ; compareBuffer[7] = (byte)0x00 ; + compareBuffer[8] = (byte)0x02 ; compareBuffer[9] = (byte)0x02 ; + compareBuffer[10] = (byte)0x82 ; compareBuffer[11] = (byte)0x81 ; + + // Compare buffers + result = Util.arrayCompare(compareBuffer, (short)0, + dstBuffer20, (short)0, (short)20) ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/Test_Api_2_Prh_Cpyv.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/Test_Api_2_Prh_Cpyv.java new file mode 100644 index 0000000000000000000000000000000000000000..635caa31091f9f30f3530d02ea1f4399bdd4a0d8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/Test_Api_2_Prh_Cpyv.java @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Cpyv.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_cpyv; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_cpyv + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Cpyv extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_cpyv"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Cpyv() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 13 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the DISPLAY TEXT proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response (No additional information) + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0DCCCCCC CCCCCCCC CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..f2ae0a492d71b6502cdf7bb54973b5c49cfbfb19 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_cpyv.Api_2_Prh_Cpyv_1 +uicc.test.toolkit.api_2_prh_cpyv +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/javacard/api_2_prh_cpyv.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/javacard/api_2_prh_cpyv.cap new file mode 100644 index 0000000000000000000000000000000000000000..fbe8323f6d0620867738bf61e4e8166d59922a69 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_cpyv/javacard/api_2_prh_cpyv.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_facrb_bs/Api_2_Prh_Facrb_Bs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_facrb_bs/Api_2_Prh_Facrb_Bs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6ff90c384d7e99e001820453dd7a1ca025a0bf79 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_facrb_bs/Api_2_Prh_Facrb_Bs_1.java @@ -0,0 +1,495 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Facrb_Bs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_facrb_bs; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_facrb_bs + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Facrb_Bs_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + private byte[] compareBuffer20 = new byte[20] ; + private byte[] compareBuffer15 = new byte[15] ; + private byte[] compareBuffer17 = new byte[17] ; + private byte[] compareBuffer = new byte[20] ; + + public final byte DCS_8_BIT_DATA = (byte)0x04; + /** + * Constructor of the applet + */ + public Api_2_Prh_Facrb_Bs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Facrb_Bs_1 thisApplet = new Api_2_Prh_Facrb_Bs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + bRes = false ; + boolean bRes2 = false ; + + // Number of tests + testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + ProactiveResponseHandler proRespHdlr = null ; + + // Result of method + short result = 0 ; + + byte tag = 0 ; + short compareOffset = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Null as compareBuffer + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + tag = TAG_COMMAND_DETAILS ; + compareOffset = (short)0 ; + proRespHdlr.findAndCompareValue(tag, null, compareOffset) ; + + } catch (NullPointerException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : compareOffset > compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + compareOffset = (short)21 ; + proRespHdlr.findAndCompareValue(tag, compareBuffer20, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + compareOffset = (short)-1 ; + proRespHdlr.findAndCompareValue(tag, compareBuffer20, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : length > compareBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + compareOffset = (short)0 ; + proRespHdlr.findAndCompareValue(tag, compareBuffer15, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + length > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + compareOffset = (short)5 ; + proRespHdlr.findAndCompareValue(tag, compareBuffer20, compareOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Unavailable element + testCaseNb = (byte) 6 ; + bRes = false ; + bRes2 = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Select a TLV + proRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + try { + tag = (byte)04 ; + compareOffset = (short)0 ; + proRespHdlr.findAndCompareValue(tag, compareBuffer20, compareOffset) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no current TLV + try { + proRespHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i= compareBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)6 ; + compareLength = (short)0 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : compareOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)-1 ; + compareLength = (short)1 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : compareLength > compareBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : compareOffset + compareLength > compareBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)3 ; + compareLength = (short)3 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : compareLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)-1 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer5, compareOffset, compareLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)7 ; + compareOffset = (short)0 ; + compareLength = (short)0 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)-1 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : compareLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)7 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + compareLength > Text String Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)0 ; + compareLength = (short)5 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Invalid parameter + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)0 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.BAD_INPUT_PARAMETER) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Unavailable Element + testCaseNb = (byte) 12 ; + bRes = false ; + bRes2 = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Select a TLV + proRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)2 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)1 ; + + // FindAndCompareValue + try { + proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer15, compareOffset, compareLength) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no selected TLV + try { + proRespHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason()==ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successful call + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i<(short)compareBuffer17.length; i++) { + compareBuffer17[i] = (byte)(i-1) ; + } + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)00) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Verify current TLV + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)17) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Successful call + testCaseNb = (byte) 15; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i<(short)compareBuffer17.length; i++) { + compareBuffer17[i] = (byte)(i-1) ; + } + compareBuffer17[16] = 0x10 ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)-1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successful call + testCaseNb = (byte) 16; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i<(short)compareBuffer17.length; i++) { + compareBuffer17[i] = (byte)(i-1) ; + } + compareBuffer17[0] = 0x03 ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)+1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Successful call + testCaseNb = (byte) 17; + bRes = false ; + + try { + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + compareBuffer20[i]=(byte)0x55 ; + } + for (short i=(short)3; i<(short)15; i++) { + compareBuffer20[i] = (byte)(i-2) ; + } + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)3 ; + compareLength = (short)12 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer20, compareOffset, compareLength) ; + + bRes = (result == (short)0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successful call + testCaseNb = (byte) 18; + bRes = false ; + + try { + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + compareBuffer20[i]=(byte)0x55 ; + } + for (short i=(short)3; i<(short)15; i++) { + compareBuffer20[i] = (byte)(i-2) ; + } + compareBuffer20[3] = (byte)0x02 ; + compareBuffer20[4] = (byte)0x01 ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)3 ; + compareLength = (short)12 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer20, compareOffset, compareLength) ; + + bRes = (result == (short)-1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 19 : Successful call + testCaseNb = (byte) 19; + bRes = false ; + + try { + + // Initialise buffers + for (short i=0; i<(short)20; i++) { + compareBuffer20[i]=(byte)0x55 ; + } + for (short i=(short)3; i<(short)15; i++) { + compareBuffer20[i] = (byte)(i-2) ; + } + compareBuffer20[13] = (byte)0x0A ; + compareBuffer20[14] = (byte)0x0D ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)2 ; + compareOffset = (short)3 ; + compareLength = (short)12 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer20, compareOffset, compareLength) ; + + bRes = (result == (short)+1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 20 : Successful call + testCaseNb = (byte)20 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Initialise buffers + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i<(short)compareBuffer17.length; i++) { + compareBuffer17[i] = (byte)(i-1) ; + } + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)17 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer17, compareOffset, compareLength) ; + + bRes = (result == (short)0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 21 : Successful call + testCaseNb = (byte)21 ; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer[0] = (byte)0x00 ; + compareBuffer[1] = (byte)0x11 ; + compareBuffer[2] = (byte)0x22 ; + compareBuffer[3] = (byte)0x33 ; + compareBuffer[4] = (byte)0x44 ; + compareBuffer[5] = (byte)0x55 ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)2 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer, compareOffset, compareLength) ; + + bRes = (result == (short)0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 22 : Successful call + testCaseNb = (byte)22 ; + bRes = false ; + + try { + + // Initialise buffers + compareBuffer[0] = (byte)0x00 ; + compareBuffer[1] = (byte)0x11 ; + compareBuffer[2] = (byte)0x22 ; + compareBuffer[3] = (byte)0x33 ; + compareBuffer[4] = (byte)0x44 ; + compareBuffer[5] = (byte)0x66 ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)2 ; + valueOffset = (short)0 ; + compareOffset = (short)0 ; + compareLength = (short)6 ; + + result = proRespHdlr.findAndCompareValue(tag, occurence, valueOffset, compareBuffer, compareOffset, compareLength) ; + + bRes = (result == (short)-1) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 23 : Successful call : search tag 8Dh + testCaseNb = (byte) 23 ; + bRes = false ; + + // Initialise TEXT and compare buffer + compareBuffer17[0] = DCS_8_BIT_DATA ; + for (short i=1; i dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + dstOffset = (short)21 ; + proRespHdlr.findAndCopyValue(tag, dstBuffer20, dstOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + dstOffset = (short)-1 ; + proRespHdlr.findAndCopyValue(tag, dstBuffer20, dstOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : length > dstBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + dstOffset = (short)0 ; + proRespHdlr.findAndCopyValue(tag, dstBuffer15, dstOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + length > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + try { + tag = TAG_TEXT_STRING ; + dstOffset = (short)5 ; + proRespHdlr.findAndCopyValue(tag, dstBuffer20, dstOffset) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Unavailable element + testCaseNb = (byte) 6 ; + bRes = false ; + bRes2 = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Select a TLV + proRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + try { + tag = (byte)04 ; + dstOffset = (short)0 ; + proRespHdlr.findAndCopyValue(tag, dstBuffer20, dstOffset) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no current TLV + try { + proRespHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + dstOffset = (short)0 ; + result = proRespHdlr.findAndCopyValue(tag, dstBuffer17, dstOffset) ; + + bRes = (result == (short)17) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Compare buffer + testCaseNb = (byte) 8 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer[0] = DCS_8_BIT_DATA ; + for (short i=1; i= dstBuffer.length + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)5 ; + dstLength = (short)1 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : dstOffset < 0 + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)-1 ; + dstLength = (short)1 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : dstLength > dstBufferLength + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)0 ; + dstLength = (short)6 ; + + try { + + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : dstOffset + dstLength > dstBuffer.length + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)3 ; + dstLength = (short)3 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : dstLength < 0 + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)0 ; + dstLength = (short)-1 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer5, dstOffset, dstLength) ; + + } catch (ArrayIndexOutOfBoundsException e) { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : valueOffset >= Text String Length + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)7 ; + dstOffset = (short)0 ; + dstLength = (short)0 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer15, dstOffset, dstLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : valueOffset < 0 + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)-1 ; + dstOffset = (short)0 ; + dstLength = (short)1 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer15, dstOffset, dstLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : dstLength > Text String length + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)0 ; + dstLength = (short)7 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer15, dstOffset, dstLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : valueOffset + dstLength > Text String Length + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)2 ; + dstOffset = (short)0 ; + dstLength = (short)5 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer15, dstOffset, dstLength) ; + + } catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Unavailable Element + testCaseNb = (byte) 11 ; + bRes = false ; + bRes2 = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Select a TLV + proRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte)1) ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)2 ; + valueOffset = (short)0 ; + dstOffset = (short)0 ; + dstLength = (short)1 ; + + try { + proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer15, dstOffset, dstLength) ; + + } catch (ToolkitException e) { + bRes2 = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + // Verify there is no current TLV + try { + proRespHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (bRes2) && (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successful call + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)0 ; + dstLength = (short)17 ; + + result = proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer17, dstOffset, dstLength) ; + + bRes = (result == (short)17) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Compare buffer + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Initialise compare buffer + compareBuffer[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)16; i++) { + compareBuffer[(short)(i+1)] = (byte)i ; + } + + result = Util.arrayCompare(compareBuffer, (short)0, dstBuffer17, (short)0, (short)17) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successful call + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + + for (short i=0; i<(short)20; i++) { + dstBuffer20[i] = (byte)0x55 ; + } + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)2 ; + dstOffset = (short)3; + dstLength = (short)12 ; + + result = proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer20, dstOffset, dstLength) ; + + bRes = (result == (short)15) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Compare buffer + testCaseNb = (byte) 15 ; + bRes = false ; + + try { + + // Initialise compare buffer + for (short i=0; i<(short)20; i++) { + compareBuffer[i] = (byte)0x55 ; + } + for (short i=3; i<(short)15; i++) { + compareBuffer[i] = (byte)(i-2) ; + } + + result = Util.arrayCompare(compareBuffer, (short)0, dstBuffer20, (short)0, (short)20) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 16 : Successful call with 2 Text String TLV + testCaseNb = (byte) 16 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)0; + dstLength = (short)17 ; + + result = proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer17, dstOffset, dstLength) ; + + bRes = (result == (short)17) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 17 : Compare buffer + testCaseNb = (byte) 17 ; + bRes = false ; + + try { + + // Initialise compare buffer + compareBuffer[0] = DCS_8_BIT_DATA ; + for (short i=0; i<(short)16; i++) { + compareBuffer[(short)(i+1)] = (byte)i ; + } + + result = Util.arrayCompare(compareBuffer, (short)0, dstBuffer17, (short)0, (short)17) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 18 : Successful call with 2 Text String TLV + testCaseNb = (byte) 18 ; + bRes = false ; + + try { + + tag = TAG_TEXT_STRING ; + occurence = (byte)2 ; + valueOffset = (short)0 ; + dstOffset = (short)0; + dstLength = (short)6 ; + + result = proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer17, dstOffset, dstLength) ; + + bRes = (result == (short)6) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 19 : Compare buffer + testCaseNb = (byte) 19 ; + bRes = false ; + + try { + + compareBuffer[0] = (byte) 0x00 ; + compareBuffer[1] = (byte) 0x11 ; + compareBuffer[2] = (byte) 0x22 ; + compareBuffer[3] = (byte) 0x33 ; + compareBuffer[4] = (byte) 0x44 ; + compareBuffer[5] = (byte) 0x55 ; + + result = Util.arrayCompare(compareBuffer, (short)0, dstBuffer17, (short)0, (short)6) ; + + bRes = (result == 0) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 20 : Successful call, tag = 8Dh + testCaseNb = (byte) 20 ; + bRes = false ; + + try { + + // Send a GET INPUT command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + tag = (byte)0x8D ; + occurence = (byte)1 ; + valueOffset = (short)0 ; + dstOffset = (short)0; + dstLength = (short)17 ; + + result = proRespHdlr.findAndCopyValue(tag, occurence, valueOffset, dstBuffer17, dstOffset, dstLength) ; + + bRes = (result == (short)17) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 21 : Compare buffer + testCaseNb = (byte) 21 ; + bRes = false ; + + // Initialise compareBuffer + compareBuffer[0] = DCS_8_BIT_DATA ; + for (short i=1; i= sLength) + { + bRes = true; + } + else + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/Test_Api_2_Prh_Gcap.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/Test_Api_2_Prh_Gcap.java new file mode 100644 index 0000000000000000000000000000000000000000..af1ac35b6cd0eade90d39c9b2bfe4021b27cf20a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/Test_Api_2_Prh_Gcap.java @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gcap.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gcap; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gcap + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gcap extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gcap"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gcap() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 3 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "03CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..c442c25527a0e08d78b22eb083d44b6bbc66846d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gcap.Api_2_Prh_Gcap_1 +uicc.test.toolkit.api_2_prh_gcap +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/javacard/api_2_prh_gcap.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/javacard/api_2_prh_gcap.cap new file mode 100644 index 0000000000000000000000000000000000000000..c5af320bad9458a7b8f4133173641cd48910100b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcap/javacard/api_2_prh_gcap.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/Api_2_Prh_Gcid_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/Api_2_Prh_Gcid_1.java new file mode 100644 index 0000000000000000000000000000000000000000..eead2028235df385dbffa928344a3633b90b850d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/Api_2_Prh_Gcid_1.java @@ -0,0 +1,223 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gcid_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gcid; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gcid + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gcid_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private final byte[] ADDRESS = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + private final byte[] BEARER_DESC = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + private final byte textBuffer[] = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'}; + + private static final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gcid_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gcid_1 thisApplet = new Api_2_Prh_Gcid_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Miscelaneous + byte bChannelNb; + + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + ProactiveResponseHandler proRespHdlr = null ; + + // Send a Display Text proactive command and get the handler + // init Display Text command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, textBuffer, (short)0, (short)textBuffer.length); + // send proactive command + proHdlr.send(); + + // Get the proactive response handler + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + + // Test Case 1 : getChannelIdentifier(), Channel status TLV is not present + // ----------------------------------------------------------------------- + testCaseNb = (byte) 1 ; + bRes = false ; + try { + proRespHdlr.getChannelIdentifier(); + bRes = false ; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Test Case 2 : getChannelIdentifier(), Channel status TLV with a length equal to 0 + // --------------------------------------------------------------------------------- + testCaseNb = (byte) 2 ; + bRes = false ; + // build an open channel command + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + // Send the command + proHdlr.send(); + + // Get the proactive response handler + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + // Get the Channel Id + try { + proRespHdlr.getChannelIdentifier(); + bRes = false ; + } + catch (ToolkitException e){ + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES ) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // Test Case 3 : getChannelIdentifier(), normal test + // ------------------------------------------------- + testCaseNb = (byte) 3 ; + bRes = false ; + // build an open channel command + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + // Send the command + proHdlr.send(); + + // Get the proactive response handler + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + // Get the Channel Id + try { + if (proRespHdlr.getChannelIdentifier() == 0x01) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + // build an close channel command + proHdlr.initCloseChannel((byte)0x01); + // Send the command + proHdlr.send(); + reportTestOutcome(testCaseNb, bRes) ; + + // Test Case 4 : getChannelIdentifier(), with 2 TLV channel id + // ----------------------------------------------------------- + testCaseNb = (byte) 4 ; + bRes = false ; + // build an open channel command + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + // Send the command + proHdlr.send(); + + // Get the proactive response handler + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + // Get the Channel Id + try { + if (proRespHdlr.getChannelIdentifier() == 0x01) + { + bRes = true ; + } + } + catch (Exception e) { + bRes = false ; + } + // build an close channel command + proHdlr.initCloseChannel((byte)0x01); + // Send the command + proHdlr.send(); + reportTestOutcome(testCaseNb, bRes) ; + + // Test Case 5 : getChannelIdentifier(), Channel status TLV is currently selected TLV + // ---------------------------------------------------------------------------------- + testCaseNb = (byte) 5 ; + bRes = false ; + // build an open channel command + proHdlr.init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + proHdlr.appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + proHdlr.appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + // Send the command + proHdlr.send(); + + // Get the proactive response handler + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + // check the currently selected TLV + try { + proRespHdlr.findTLV(TAG_DEVICE_IDENTITIES, (byte) 0x01); + if ((proRespHdlr.getChannelIdentifier() == (byte) 0x03) && + (proRespHdlr.getChannelIdentifier() == proRespHdlr.getValueByte((byte)0x00))) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/Test_Api_2_Prh_Gcid.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/Test_Api_2_Prh_Gcid.java new file mode 100644 index 0000000000000000000000000000000000000000..b2d3740fce74a750f398b6ea13ab6ffa70fecf5c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/Test_Api_2_Prh_Gcid.java @@ -0,0 +1,182 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gcid.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gcid; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gcid + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gcid extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gcid"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gcid() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch Display Text + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Open channel proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Terminal response with channel status TLV length set to 00 + response = test.terminalResponse("81030140 01820282 81030220 00380035" + + "04010000 00390200 80"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Open channel proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Terminal response OK on channel 01 + response = test.terminalResponse("81030140 01820282 81030100 38028100" + + "35040100 00003902 0080"); + result &= response.checkSw("910B"); + + // Close channel proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Terminal response OK + response = test.terminalResponse("81030141 00820282 81030100"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Open channel proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Terminal response with 2 Channel Id TLV + response = test.terminalResponse("81030140 01820282 81030100 38028100" + + "38028200 35040100 00003902 0080"); + result &= response.checkSw("910B"); + + // Close channel proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Terminal response OK + response = test.terminalResponse("81030141 00820282 81030100"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Open channel proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Terminal response + response = test.terminalResponse("81030140 01820282 81030100 38020305" + + "35040100 00003902 0080"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "05CCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..931c72019c5e80c8e1eef7e443dcbb25eeb0374a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gcid.Api_2_Prh_Gcid_1 +uicc.test.toolkit.api_2_prh_gcid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/javacard/api_2_prh_gcid.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/javacard/api_2_prh_gcid.cap new file mode 100644 index 0000000000000000000000000000000000000000..75a72c3cc9f30595cd80ce935aed30eb8b743b62 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcid/javacard/api_2_prh_gcid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/Api_2_Prh_Gcst_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/Api_2_Prh_Gcst_1.java new file mode 100644 index 0000000000000000000000000000000000000000..0f37a5aeac4d18b6988153c8eadced1581a8a6cc --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/Api_2_Prh_Gcst_1.java @@ -0,0 +1,281 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gcst_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gcst; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gcst + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gcst_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + private byte[] ADDRESS = {(byte)0x91, (byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44} ; + private byte[] BEARER_DESC = {(byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00}; + private byte[] menuEntry = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)' ',(byte)'1'}; + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gcst_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gcst_1 thisApplet = new Api_2_Prh_Gcst_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Miscelaneous + short ChannelStatusValue; + + // Get the system instance of handlers + ProactiveResponseHandler ProRespHdlr = ProactiveResponseHandlerSystem.getTheHandler(); + + // ---------------------------------------------------------------- + // Test Case 1 : Get channel Status TLV is not present + testCaseNb = (byte)1; + bRes = false ; + try { + (ProactiveHandlerSystem.getTheHandler()).initDisplayText((byte)00,DCS_8_BIT_DATA,TEXT,(short)0,(short)TEXT.length); + (ProactiveHandlerSystem.getTheHandler()).send(); + try{ + ProRespHdlr.getChannelStatus((byte)0x01); + bRes = false; + } + catch(ToolkitException e) + { + if(e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + } + catch (Exception e) + { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------------------------------- + // Test Case 2 : Channel status TLV with the identifier is not present + testCaseNb = (byte)2; + bRes = false; + + // Send an OPEN CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + ProRespHdlr.getChannelStatus((byte)0x02); + } + catch(ToolkitException e){ + if(e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + // Send a CLOSE CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).initCloseChannel((byte)0x01); + (ProactiveHandlerSystem.getTheHandler()).send(); + + reportTestOutcome(testCaseNb, bRes) ; + + // ------------------------------------------------------ + // Test Case 3 : Channel status TLV with length set to 0. + testCaseNb = (byte)3; + bRes = false; + + // Send an OPEN CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + ProRespHdlr.getChannelStatus((byte)0x01); + } + catch(ToolkitException e){ + if(e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ------------------------------------------------------ + // Test Case 4 : Channel status TLV with length set to 1. + testCaseNb = (byte)4; + bRes = false; + + // Send an OPEN CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + ProRespHdlr.getChannelStatus((byte)0x01); + } + catch(ToolkitException e){ + if(e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) + bRes = true; + } + catch (Exception e) + { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ------------------------------------------------------ + // Test Case 5 : Get channel status value + testCaseNb = (byte)5; + bRes = false; + + // Send an OPEN CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + ChannelStatusValue = ProRespHdlr.getChannelStatus((byte)0x01); + bRes = (ChannelStatusValue == (short)0x8100); + } + catch (Exception e) + { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ------------------------------------------------------ + // Test Case 6 : Get channel status value with 2 TLVs + testCaseNb = (byte)6; + bRes = false; + + // Send an GET_CHANNEL_STATUS proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_GET_CHANNEL_STATUS, (byte)0x00, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + ChannelStatusValue = ProRespHdlr.getChannelStatus((byte)0x01); + bRes = (ChannelStatusValue == (short)0x8100); + } + catch (Exception e) + { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ------------------------------------------------------ + // Test Case 7 : Get channel status value with 2 TLVs + testCaseNb = (byte)7; + bRes = false; + + // Send an GET_CHANNEL_STATUS proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_GET_CHANNEL_STATUS, (byte)0x00, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + ChannelStatusValue = ProRespHdlr.getChannelStatus((byte)0x01); + bRes = (ChannelStatusValue == (short)0x8100); + } + catch (Exception e) + { + bRes = false; + } + + // Send a CLOSE CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).initCloseChannel((byte)0x01); + (ProactiveHandlerSystem.getTheHandler()).send(); + + reportTestOutcome(testCaseNb, bRes) ; + + // --------------------------------------------------------------- + // Test Case 8 : Channel Status TLV is the currently selected TLV + testCaseNb = (byte)8; + bRes = false; + + // Send an OPEN CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).init(PRO_CMD_OPEN_CHANNEL, (byte)0x01, DEV_ID_TERMINAL); + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_ADDRESS, ADDRESS, (short)0x00, (short)ADDRESS.length); + // CSD Bearer Description + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BEARER_DESCRIPTION, BEARER_DESC, (short)0x00, (short)BEARER_DESC.length); + // Buffer size + (ProactiveHandlerSystem.getTheHandler()).appendTLV(TAG_BUFFER_SIZE, (byte)0x00, (byte)0x80); + (ProactiveHandlerSystem.getTheHandler()).send() ; + + try{ + // Select the device identities TLV + ProRespHdlr.findTLV(TAG_DEVICE_IDENTITIES,(byte)0x01); + ChannelStatusValue = ProRespHdlr.getChannelStatus((byte)0x03); + bRes = (ChannelStatusValue == (short)0x8304); + bRes &= (ChannelStatusValue == ProRespHdlr.getValueShort((short)0)); + } + catch (Exception e) + { + bRes = false; + } + + // Send a CLOSE CHANNEL proactive command + (ProactiveHandlerSystem.getTheHandler()).initCloseChannel((byte)0x03); + (ProactiveHandlerSystem.getTheHandler()).send(); + + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/Test_Api_2_Prh_Gcst.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/Test_Api_2_Prh_Gcst.java new file mode 100644 index 0000000000000000000000000000000000000000..e3c285e299ff078493f6acea5d2cb3f94dce2fe2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/Test_Api_2_Prh_Gcst.java @@ -0,0 +1,231 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gcst.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gcst; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gcst + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gcst extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gcst"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gcst() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the DISPLAY TEXT proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no CHANNEL STATUS TLV + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Fetch the OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Successful terminal response with channel status value set to 0x8100 + response = test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + result &= response.checkSw("910B"); + + // Fetch the CLOSE CHANNEL proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Successful terminal response + response = test.terminalResponse("81030141 00820282 81830100"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Fetch the OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Unsuccessful terminal response with channel status TLV length set to 0 + response = test.terminalResponse("81030140 01820282 81830130 38003502" + + "03003902 000A"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Fetch the OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Unsuccessful terminal response with channel status TLV length set to 1 + response = test.terminalResponse("81030140 01820282 81830130 38018135" + + "02030039 02000A"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Fetch the OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Successful terminal response with channel status TLV value set to 0x8100 + response = test.terminalResponse("81030140 01820282 81830100 38028100" + + "35020300 3902000A"); + result &= response.checkSw("910B"); + + /*********************************************************************/ + /** Testcase 6 */ + /*********************************************************************/ + + // Fetch the GET CHANNEL STATUS proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01440082 028182"); + + // Successful terminal response with 2 channel status TLVs + response = test.terminalResponse("81030144 01820282 81830100 38028100" + + "38028101 35020300 3902000A"); + result &= response.checkSw("910B"); + + /*********************************************************************/ + /** Testcase 7 */ + /*********************************************************************/ + + // Fetch the GET CHANNEL STATUS proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01440082 028182"); + + // Successful terminal response with 2 channel status TLVs + response = test.terminalResponse("81030144 01820282 81830100 38028200" + + "38028100 35020300 3902000A"); + result &= response.checkSw("910B"); + + // Fetch the CLOSE CHANNEL proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028121"); + + // Successful terminal response + response = test.terminalResponse("81030141 00820282 81830100"); + result &= response.checkSw("911C"); + + /*********************************************************************/ + /** Testcase 8 */ + /*********************************************************************/ + + // Fetch the OPEN CHANNEL proactive command + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01400182 02818206 05911122" + + "33443504 01000000 39020080"); + + // Successful terminal response with 1 channel status TLVs + response = test.terminalResponse("81030140 01820282 81830100 38028304" + + "35020300 3902000A"); + result &= response.checkSw("910B"); + + // Fetch the CLOSE CHANNEL proactive command + response = test.fetch("0B"); + result &= response.checkData("D0098103 01410082 028123"); + + // Successful terminal response + response = test.terminalResponse("81030141 00820282 81830100"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ca7989222157742ee93c2971c32e9b9629fd6851 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gcst.Api_2_Prh_Gcst_1 +uicc.test.toolkit.api_2_prh_gcst +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/javacard/api_2_prh_gcst.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/javacard/api_2_prh_gcst.cap new file mode 100644 index 0000000000000000000000000000000000000000..557a299d6e356fe02eca74d6d1c44545207ff1ba Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gcst/javacard/api_2_prh_gcst.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/Api_2_Prh_Glen_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/Api_2_Prh_Glen_1.java new file mode 100644 index 0000000000000000000000000000000000000000..6ea892460bd1aa90f11f587f75c707d7d35153be --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/Api_2_Prh_Glen_1.java @@ -0,0 +1,120 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Glen_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_glen; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_glen + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Glen_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Glen_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Glen_1 thisApplet = new Api_2_Prh_Glen_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // Response handler + ProactiveResponseHandler proRespHdlr ; + + // -------------------------------------------- + // Test Case 1 : length = 12 + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify length of the response + bRes = (proRespHdlr.getLength() == (short)12) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : length = FFh + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify length of the response + bRes = (proRespHdlr.getLength() == (short)0xFF) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/Test_Api_2_Prh_Glen.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/Test_Api_2_Prh_Glen.java new file mode 100644 index 0000000000000000000000000000000000000000..1dcc940f0fc111f09336f029bd06883014d452ce --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/Test_Api_2_Prh_Glen.java @@ -0,0 +1,139 @@ +//----------------------------------------------------------------------------- +//Test_Api_Prh_Glen.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_glen; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_glen + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Glen extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_glen"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Glen() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the DISPLAY TEXT proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no additional information + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response (F2h additional bytes) + response = test.terminalResponse("81030121 00020282 810381F3 01000102" + + "03040506 0708090A 0B0C0D0E 0F101112" + + "13141516 1718191A 1B1C1D1E 1F202122" + + "23242526 2728292A 2B2C2D2E 2F303132" + + "33343536 3738393A 3B3C3D3E 3F404142" + + "43444546 4748494A 4B4C4D4E 4F505152" + + "53545556 5758595A 5B5C5D5E 5F606162" + + "63646566 6768696A 6B6C6D6E 6F707172" + + "73747576 7778797A 7B7C7D7E 7F808182" + + "83848586 8788898A 8B8C8D8E 8F909192" + + "93949596 9798999A 9B9C9D9E 9FA0A1A2" + + "A3A4A5A6 A7A8A9AA ABACADAE AFB0B1B2" + + "B3B4B5B6 B7B8B9BA BBBCBDBE BFC0C1C2" + + "C3C4C5C6 C7C8C9CA CBCCCDCE CFD0D1D2" + + "D3D4D5D6 D7D8D9DA DBDCDDDE DFE0E1E2" + + "E3E4E5E6 E7E8E9EA EBECEDEE EFF0F1"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "02CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d008ee570463ce08fe3b9b0b51884575c45496bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_glen.Api_2_Prh_Glen_1 +uicc.test.toolkit.api_2_prh_glen +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/javacard/api_2_prh_glen.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/javacard/api_2_prh_glen.cap new file mode 100644 index 0000000000000000000000000000000000000000..93eb1b6f290989d687386338c6a1a43e179291d9 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_glen/javacard/api_2_prh_glen.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/Api_2_Prh_Gtcs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/Api_2_Prh_Gtcs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..13b88e245af7fe2be620111a965d287813550b5f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/Api_2_Prh_Gtcs_1.java @@ -0,0 +1,406 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gtcs_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtcs; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtcs + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gtcs_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gtcs_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gtcs_1 thisApplet = new Api_2_Prh_Gtcs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + ProactiveResponseHandler proRespHdlr = null ; + + short result = (short) 0 ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Text String TLV + + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // getTextStringCodingScheme() with unavailable Text String TLV + result = proRespHdlr.getTextStringCodingScheme() ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Null Text String TLV + + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // getTextStringCodingScheme() with null Text String TLV + result = proRespHdlr.getTextStringCodingScheme() ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successfull call + + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringCodingScheme() ; + + bRes = (result == (short)0x04) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Verify the TLV selected + + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successfull call + + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringCodingScheme() ; + + bRes = (result == (short)0x00) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Verify the TLV selected + + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x03) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successfull call + + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringCodingScheme() ; + + bRes = (result == (short)0x08) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Verify the TLV selected + + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x7F) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Successfull call + + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringCodingScheme() ; + + bRes = (result == (short)0x04) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Verify the TLV selected + + testCaseNb = (byte) 10 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x80) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Successfull call + + testCaseNb = (byte) 11 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringCodingScheme() ; + + bRes = (result == (short)0x08) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Verify the TLV selected + + testCaseNb = (byte) 12 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0xF0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Successfull call + // Terminal Response with 2 Text String TLV + + testCaseNb = (byte) 13 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringCodingScheme() ; + + bRes = (result == (short)0x04) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 14 : Verify the TLV selected + + testCaseNb = (byte) 14 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/Test_Api_2_Prh_Gtcs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/Test_Api_2_Prh_Gtcs.java new file mode 100644 index 0000000000000000000000000000000000000000..26c3961300988d8f26fa87f0f1d26cf947222e3a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/Test_Api_2_Prh_Gtcs.java @@ -0,0 +1,235 @@ +//----------------------------------------------------------------------------- +//Test_Api_Prh_Gtcs.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtcs; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtcs + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gtcs extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gtcs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gtcs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no additional information + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 2 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string TLV is null) + response = test.terminalResponse("81030123 00020282 81030100 0D00"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 3 & 4 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 01h) + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 5 & 6 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 02h) + response = test.terminalResponse("81030123 00020282 81030100 0D030042" + + "42"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 7 & 8 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 7Eh) + response = test.terminalResponse("81030123 00020282 81030100 0D7F0801" + + "02030405 06070809 0A0B0C0D 0E0F1011" + + "12131415 16171819 1A1B1C1D 1E1F2021" + + "22232425 26272829 2A2B2C2D 2E2F3031" + + "32333435 36373839 3A3B3C3D 3E3F4041" + + "42434445 46474849 4A4B4C4D 4E4F5051" + + "52535455 56575859 5A5B5C5D 5E5F6061" + + "62636465 66676869 6A6B6C6D 6E6F7071" + + "72737475 76777879 7A7B7C7D 7E"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 9 & 10 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 7Fh) + response = test.terminalResponse("81030123 00020282 81030100 0D818004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 11 & 12 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = EFh) + response = test.terminalResponse("81030123 00020282 81030100 0D81F008" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0" + + "D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0" + + "E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEF"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 13 & 14 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (2 Text string TLVs) + response = test.terminalResponse("81030123 00020282 81030100 0D020441" + + "0D030842 43"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5ffb6f0dc24d21e57dfd06364a96676e5ba48456 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gtcs.Api_2_Prh_Gtcs_1 +uicc.test.toolkit.api_2_prh_gtcs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/javacard/api_2_prh_gtcs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/javacard/api_2_prh_gtcs.cap new file mode 100644 index 0000000000000000000000000000000000000000..60d1635fe2ce4f0dcfe830b8ab9df1595cfc797d Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtcs/javacard/api_2_prh_gtcs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/Api_2_Prh_Gtgr_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/Api_2_Prh_Gtgr_1.java new file mode 100644 index 0000000000000000000000000000000000000000..82f43785430813a0358ca56b97bd6ba46d9011d4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/Api_2_Prh_Gtgr_1.java @@ -0,0 +1,411 @@ +//----------------------------------------------------------------------------- +//Api_2_Pah_Gtgr_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtgr; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtgr + * + * @version 0.0.1 - 23 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gtgr_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gtgr_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gtgr_1 thisApplet = new Api_2_Prh_Gtgr_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // System instance of the ProactiveResponseHandler class + ProactiveResponseHandler proRespHdlr = null ; + + + // -------------------------------------------- + // Test Case 1 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // RES_CMD_PERF = 00 (Command performed successfully) + bRes = (proRespHdlr.getGeneralResult() == RES_CMD_PERF) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Verify the Result TLV is selected + + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x01) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // RES_CMD_PERF_PARTIAL_COMPR = 01 (Command performed successfully) + bRes = (proRespHdlr.getGeneralResult() == RES_CMD_PERF_PARTIAL_COMPR) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Verify the Result TLV is selected + + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x01) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // RES_CMD_PERF_PARTIAL_COMPR = 01 (Partial comprehension) + bRes = (proRespHdlr.getGeneralResult() == RES_CMD_PERF_PARTIAL_COMPR) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Verify the Result TLV is selected + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // RES_CMD_PERF_MISSING_INFO = 02 + bRes = (proRespHdlr.getGeneralResult() == RES_CMD_PERF_MISSING_INFO) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Verify the Result TLV is selected + + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x04) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Build and send a DISPLAY TEXT command + // get the result (7Fh additional bytes) + + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // RES_CMD_PERF_MISSING_INFO = 02 + bRes = (proRespHdlr.getGeneralResult() == RES_CMD_PERF_MISSING_INFO) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Verify the Result TLV is selected + + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x80) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Build and send a DISPLAY TEXT command + // get the result (2 Result TLV) + + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // RES_CMD_PERF_MISSING_INFO = 02 + bRes = (proRespHdlr.getGeneralResult() == RES_CMD_PERF_MISSING_INFO) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Verify the Result TLV is selected + + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : No Result Simple TLV in Terminal Response + + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + try { + // Send + proHdlr.send() ; + } + catch (Exception e) { + } + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // UNAVAILABLE_ELEMENT ToolkitException + + try { + + short result = proRespHdlr.getGeneralResult() ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : General Result Byte missing in Result Simple TLV + + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + try { + // Send + proHdlr.send() ; + } + catch (Exception e) { + } + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // OUT_OF_TLV_BOUNDARIES ToolkitException + + try { + + short result = proRespHdlr.getGeneralResult() ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/Test_Api_2_Prh_Gtgr.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/Test_Api_2_Prh_Gtgr.java new file mode 100644 index 0000000000000000000000000000000000000000..1b4399b43bbb6734f8b5c91f69b3ecdcb5e5b962 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/Test_Api_2_Prh_Gtgr.java @@ -0,0 +1,212 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gtgr.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtgr; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtgr + * + * @version 0.0.1 - 23 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gtgr extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gtgr"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gtgr() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 & 2 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + + /*********************************************************************/ + /** Testcase 3 & 4 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response + response = test.terminalResponse("81030121 00020282 81030101"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 5 & 6 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response + response = test.terminalResponse("81030121 00020282 81030201 55"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 7 & 8 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response + response = test.terminalResponse("81030121 00020282 81030402 654321"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 9 & 10 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 7Fh additional information + response = test.terminalResponse("81030121 00020282 81038180 02555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 11 & 12 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 2 result TLVs + response = test.terminalResponse("81030121 00020282 81030202 12030303" + + "3456"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no result TLV + response = test.terminalResponse("81030121 00020282 81"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 13 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no general result + response = test.terminalResponse("81030121 00020282 810300"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0ECCCCCC CCCCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d90903aae02aa9d875d89c18813368ea4b323547 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gtgr.Api_2_Prh_Gtgr_1 +uicc.test.toolkit.api_2_prh_gtgr +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/javacard/api_2_prh_gtgr.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/javacard/api_2_prh_gtgr.cap new file mode 100644 index 0000000000000000000000000000000000000000..5de963e570d7cea0e1c601c4977a260fd4649d8f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtgr/javacard/api_2_prh_gtgr.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/Api_2_Prh_Gtii_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/Api_2_Prh_Gtii_1.java new file mode 100644 index 0000000000000000000000000000000000000000..eec56ec0f6eb731825e0fddda3f83db6677dbee6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/Api_2_Prh_Gtii_1.java @@ -0,0 +1,349 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gtii_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtii; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtii + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gtii_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + private byte[] ITEM1 = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'1'} ; + private byte[] ITEM2 = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'2'} ; + private byte[] ITEM3 = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'3'} ; + private byte[] ITEM5 = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'5'} ; + private byte[] ITEM7 = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'7'} ; + private byte[] ITEMFD = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'D'} ; + private byte[] ITEMFE = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'E'} ; + private byte[] ITEMFF = {(byte)'I',(byte)'t',(byte)'e',(byte)'m',(byte)'F'} ; + + private static final byte ITEM1_ID = (byte) 1 ; + private static final byte ITEM2_ID = (byte) 2 ; + private static final byte ITEM3_ID = (byte) 3 ; + private static final byte ITEM5_ID = (byte) 5 ; + private static final byte ITEM7_ID = (byte) 7 ; + private static final byte ITEMFD_ID = (byte) 0xFD ; + private static final byte ITEMFE_ID = (byte) 0xFE ; + private static final byte ITEMFF_ID = (byte) 0xFF ; + + private static final byte TAG_ITEM_CR = (byte)(TAG_ITEM | TAG_SET_CR) ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gtii_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gtii_1 thisApplet = new Api_2_Prh_Gtii_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + ProactiveResponseHandler proRespHdlr = null ; + + short result = (short) 0 ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Item Identifier TLV + + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // getItemIdentifier() with unavailable Item Identifier TLV + result = proRespHdlr.getItemIdentifier() ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Successfull call + + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + + // Build and send a SELECT ITEM proactive command + proHdlr.init(PRO_CMD_SELECT_ITEM, (byte)0, DEV_ID_TERMINAL) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEM1_ID, ITEM1, (short)0, (short)ITEM1.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEM2_ID, ITEM2, (short)0, (short)ITEM2.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getItemIdentifier() ; + + bRes = (result == ITEM1_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Verify the TLV selected + + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + + // Get 1st byte of the current TLV + result = proRespHdlr.getValueByte((short)0x00) ; + + bRes = (result == ITEM1_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successfull call + + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + + // Build and send a SELECT ITEM proactive command + proHdlr.init(PRO_CMD_SELECT_ITEM, (byte)0, DEV_ID_TERMINAL) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEM3_ID, ITEM3, (short)0, (short)ITEM3.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEM5_ID, ITEM5, (short)0, (short)ITEM5.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEM7_ID, ITEM7, (short)0, (short)ITEM7.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getItemIdentifier() ; + + bRes = (result == ITEM5_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Verify the TLV selected + + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + + // Get 1st byte of the current TLV + result = proRespHdlr.getValueByte((short)0x00) ; + + bRes = (result == ITEM5_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successfull call + + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + + // Build and send a SELECT ITEM proactive command + proHdlr.init(PRO_CMD_SELECT_ITEM, (byte)0, DEV_ID_TERMINAL) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEMFD_ID, ITEMFD, (short)0, (short)ITEMFD.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEMFE_ID, ITEMFE, (short)0, (short)ITEMFE.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEMFF_ID, ITEMFF, (short)0, (short)ITEMFF.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getItemIdentifier() ; + + bRes = (result == ITEMFF_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Verify the TLV selected + + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + + // Get 1st byte of the current TLV + result = proRespHdlr.getValueByte((short)0x00) ; + + bRes = (result == ITEMFF_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successfull call (Response with 2 Item Identifier TLV) + + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + + // Build and send a SELECT ITEM proactive command + proHdlr.init(PRO_CMD_SELECT_ITEM, (byte)0, DEV_ID_TERMINAL) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEMFD_ID, ITEMFD, (short)0, (short)ITEMFD.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEMFE_ID, ITEMFE, (short)0, (short)ITEMFE.length) ; + proHdlr.appendTLV(TAG_ITEM_CR, ITEMFF_ID, ITEMFF, (short)0, (short)ITEMFF.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getItemIdentifier() ; + + bRes = (result == ITEMFF_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Verify the TLV selected + + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + + // Get 1st byte of the current TLV + result = proRespHdlr.getValueByte((short)0x00) ; + + bRes = (result == ITEMFF_ID) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + // -------------------------------------------- + // Test Case 10 : No value in Item Identifier Simple TLV + + testCaseNb = (byte) 10 ; + + bRes = false ; + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // getItemIdentifier() without item identifier byte + result = proRespHdlr.getItemIdentifier() ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/Test_Api_2_Prh_Gtii.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/Test_Api_2_Prh_Gtii.java new file mode 100644 index 0000000000000000000000000000000000000000..0c04bcd29f49d1cac682bd0910e85e0db61fd4d0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/Test_Api_2_Prh_Gtii.java @@ -0,0 +1,181 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gtii.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtii; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtii + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gtii extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gtii"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gtii() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no additional information + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("911B"); + + + /*********************************************************************/ + /** Testcase 2 & 3 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("1B"); + result &= response.checkData("D0198103 01240082 0281828F 06014974" + + "656D318F 06024974 656D32"); + + // Terminal response (SELECT ITEM) + response = test.terminalResponse("81030124 00020282 81030100 100101"); + result &= response.checkSw("9123"); + + /*********************************************************************/ + /** Testcase 4 & 5 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("23"); + result &= response.checkData("D0218103 01240082 0281828F 06034974" + + "656D338F 06054974 656D358F 06074974" + + "656D37"); + + // Terminal response (SELECT ITEM) + response = test.terminalResponse("81030124 00020282 81030100 100105"); + result &= response.checkSw("9123"); + + /*********************************************************************/ + /** Testcase 6 & 7 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("23"); + result &= response.checkData("D0218103 01240082 0281828F 06FD4974" + + "656D448F 06FE4974 656D458F 06FF4974" + + "656D46"); + + // Terminal response (SELECT ITEM) + response = test.terminalResponse("81030124 00020282 81030100 1001FF"); + result &= response.checkSw("9123"); + + /*********************************************************************/ + /** Testcase 8 & 9 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("23"); + result &= response.checkData("D0218103 01240082 0281828F 06FD4974" + + "656D448F 06FE4974 656D458F 06FF4974" + + "656D46"); + + // Terminal response (SELECT ITEM) + response = test.terminalResponse("81030124 00020282 81030100 1001FF10" + + "01FE"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 10 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no item identifier + response = test.terminalResponse("81030121 00020282 81030100 1000"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0ACCCCCC CCCCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9063916d86c8b71393d8cff93e0952060eaac83f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gtii.Api_2_Prh_Gtii_1 +uicc.test.toolkit.api_2_prh_gtii +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/javacard/api_2_prh_gtii.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/javacard/api_2_prh_gtii.cap new file mode 100644 index 0000000000000000000000000000000000000000..f27b1e22ac99e627dfd7fb920af277027e7932a3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtii/javacard/api_2_prh_gtii.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/Api_2_Prh_Gtil_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/Api_2_Prh_Gtil_1.java new file mode 100644 index 0000000000000000000000000000000000000000..199c0315bd0c4021f2693989a28ff91b6e257b81 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/Api_2_Prh_Gtil_1.java @@ -0,0 +1,418 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gtil_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtil; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtil + * + * @version 0.0.1 - 23 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gtil_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gtil_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gtil_1 thisApplet = new Api_2_Prh_Gtil_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + // System instance of the ProactiveResponseHandler class + ProactiveResponseHandler proRespHdlr = null ; + + + // -------------------------------------------- + // Test Case 1 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x0000) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Verify the Result TLV is selected + + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x0001) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x0001) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Verify the Result TLV is selected + + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x0002) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x007E) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Verify the Result TLV is selected + + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x007F) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x007F) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Verify the Result TLV is selected + + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x0080) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 9 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x0080) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Verify the Result TLV is selected + + testCaseNb = (byte) 10 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x0081) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Build and send a DISPLAY TEXT command + // get the result + + testCaseNb = (byte) 11 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x00F2) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Verify the Result TLV is selected + + testCaseNb = (byte) 12 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x00F3) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Build and send a DISPLAY TEXT command + // get the result (with 2 Result TLV) + + testCaseNb = (byte) 13 ; + bRes = false ; + + try { + + // Build the command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send + proHdlr.send() ; + + // Get the result + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Verify the additional information length + bRes = (proRespHdlr.getAdditionalInformationLength() == (short)0x0002) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Verify the Result TLV is selected + + testCaseNb = (byte) 14 ; + bRes = false ; + + try { + + bRes = (proRespHdlr.getValueLength() == (short) 0x0003) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : ToolkitException.UNAVAILABLE_ELEMENT is thrown if there is no + // General Result TLV in Terminal Response + + testCaseNb = 15 ; + bRes = false ; + + try { + + // Build a DISPLAY TEXT command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + // Send the command (no General Result TLV in Response) + try { + proHdlr.send() ; + } + catch (ToolkitException e) {} + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Get Additional Information length + try { + + proRespHdlr.getAdditionalInformationLength() ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + + } + + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/Test_Api_2_Prh_Gtil.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/Test_Api_2_Prh_Gtil.java new file mode 100644 index 0000000000000000000000000000000000000000..bd7a78560d677cc4fc5a7eea35c6197e73d6bd9e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/Test_Api_2_Prh_Gtil.java @@ -0,0 +1,243 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gtil.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gtil; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gtil + * + * @version 0.0.1 - 23 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gtil extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gtil"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gtil() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 & 2 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no additional information + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9112"); + + + /*********************************************************************/ + /** Testcase 3 & 4 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 1 additional byte + response = test.terminalResponse("81030121 00020282 81030202 55"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 5 & 6 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 7Eh additional bytes + response = test.terminalResponse("81030121 00020282 81037F02 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 5555"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 7 & 8 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 7Fh additional bytes + response = test.terminalResponse("81030121 00020282 81038180 02555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 9 & 10 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 80h additional bytes + response = test.terminalResponse("81030121 00020282 81038181 02555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 11 & 12 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with F2h additional bytes + response = test.terminalResponse("81030121 00020282 810381F3 02555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 55555555" + + "55555555 55555555 55555555 555555"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 13 & 14 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with 2 result TLVs + response = test.terminalResponse("81030121 00020282 81030302 01230301" + + "00"); + result &= response.checkSw("9112"); + + /*********************************************************************/ + /** Testcase 15 */ + /*********************************************************************/ + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no result TLV + response = test.terminalResponse("81030121 00020282 81"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0FCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..b84f89d37740c9a82670422562e5ff983edde34c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gtil.Api_2_Prh_Gtil_1 +uicc.test.toolkit.api_2_prh_gtil +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/javacard/api_2_prh_gtil.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/javacard/api_2_prh_gtil.cap new file mode 100644 index 0000000000000000000000000000000000000000..2eafaa03a498574e18a84c323ae11a56cd042d76 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gtil/javacard/api_2_prh_gtil.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/Api_2_Prh_Gttl_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/Api_2_Prh_Gttl_1.java new file mode 100644 index 0000000000000000000000000000000000000000..83a1ecce4005cea37924a0b5aafc1ef64cc69f27 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/Api_2_Prh_Gttl_1.java @@ -0,0 +1,423 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gttl_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gttl; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gttl + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gttl_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + public final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gttl_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gttl_1 thisApplet = new Api_2_Prh_Gttl_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + ProactiveResponseHandler proRespHdlr = null ; + + short result = (short) 0 ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Text String TLV + + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + + // Build and send a proactive command + proHdlr.initDisplayText((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + + // getTextStringLength() with unavailable Text String TLV + result = proRespHdlr.getTextStringLength() ; + + } catch (ToolkitException e) { + + if (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) { + bRes = true ; + } + } + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Successfull call (Null Text String) + + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0x00) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Verify the TLV selected + + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x00) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successfull call + + testCaseNb = (byte) 4 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0x01) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Verify the TLV selected + + testCaseNb = (byte) 5 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successfull call + + testCaseNb = (byte) 6 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Verify the TLV selected + + testCaseNb = (byte) 7 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x03) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successfull call + + testCaseNb = (byte) 8 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0x7E) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 9 : Verify the TLV selected + + testCaseNb = (byte) 9 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x7F) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 10 : Successfull call + + testCaseNb = (byte) 10 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0x7F) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 11 : Verify the TLV selected + + testCaseNb = (byte) 11 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x80) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 12 : Successfull call + + testCaseNb = (byte) 12 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0xEF) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 13 : Verify the TLV selected + + testCaseNb = (byte) 13 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0xF0) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 14 : Successfull call, 2 Text String TLV + + testCaseNb = (byte) 14 ; + + bRes = false ; + try { + + // Build and send a GET INPUT proactive command + proHdlr.initGetInput((byte)0x00, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0x00, (short)0xFF) ; + + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + result = proRespHdlr.getTextStringLength() ; + + bRes = (result == (short)0x01) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 15 : Verify the TLV selected + + testCaseNb = (byte) 15 ; + + bRes = false ; + try { + + // Get length of current TLV + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x02) ; + + } catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/Test_Api_2_Prh_Gttl.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/Test_Api_2_Prh_Gttl.java new file mode 100644 index 0000000000000000000000000000000000000000..5ed5ea22a7844a6fbb4623c72cc22da3e22f02f5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/Test_Api_2_Prh_Gttl.java @@ -0,0 +1,235 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gttl.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gttl; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gttl + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gttl extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gttl"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gttl() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9112"); + + // Fetch the proactive command + response = test.fetch("12"); + result &= response.checkData("D0108103 01210082 0281028D 05045465" + + "7874"); + + // Terminal response with no additional information + response = test.terminalResponse("81030121 00020282 81030100"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 2 & 3 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string TLV is null) + response = test.terminalResponse("81030123 00020282 81030100 0D00"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 4 & 5 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 01h) + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 6 & 7 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 02h) + response = test.terminalResponse("81030123 00020282 81030100 0D030042" + + "42"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 8 & 9 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 7Eh) + response = test.terminalResponse("81030123 00020282 81030100 0D7F0801" + + "02030405 06070809 0A0B0C0D 0E0F1011" + + "12131415 16171819 1A1B1C1D 1E1F2021" + + "22232425 26272829 2A2B2C2D 2E2F3031" + + "32333435 36373839 3A3B3C3D 3E3F4041" + + "42434445 46474849 4A4B4C4D 4E4F5051" + + "52535455 56575859 5A5B5C5D 5E5F6061" + + "62636465 66676869 6A6B6C6D 6E6F7071" + + "72737475 76777879 7A7B7C7D 7E"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 10 & 11 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = 7Fh) + response = test.terminalResponse("81030123 00020282 81030100 0D818004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 12 & 14 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text string length = EFh) + response = test.terminalResponse("81030123 00020282 81030100 0D81F004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0" + + "D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0" + + "E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEF"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 14 & 15 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (2 Text string TLVs) + response = test.terminalResponse("81030123 00020282 81030100 0D020441" + + "0D030842 43"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0FCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..5d7f1b7a37f7dd17e3bc70764b1d6240e3afdff0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gttl.Api_2_Prh_Gttl_1 +uicc.test.toolkit.api_2_prh_gttl +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/javacard/api_2_prh_gttl.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/javacard/api_2_prh_gttl.cap new file mode 100644 index 0000000000000000000000000000000000000000..50fc2db9156e05667352a140998ccdb136ad8c02 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gttl/javacard/api_2_prh_gttl.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/Api_2_Prh_Gvby_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/Api_2_Prh_Gvby_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f10ca0091070de81dfe804d57ca89782b89c0238 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/Api_2_Prh_Gvby_1.java @@ -0,0 +1,263 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gvby_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gvby; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gvby + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gvby_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + public final byte DCS_8_BIT_DATA = (byte)0x04; + /** + * Constructor of the applet + */ + public Api_2_Prh_Gvby_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gvby_1 thisApplet = new Api_2_Prh_Gvby_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + ProactiveResponseHandler proRespHdlr = null ; + + // Result of method + short result = 0 ; + short valueOffset = 0 ; + byte tag = 0 ; + byte occurence = 0 ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + valueOffset = (short)0 ; + proHdlr.getValueByte(valueOffset) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 2 : Out of Tlv Boundaries + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_COMMAND_DETAILS ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + try { + valueOffset = (short)3 ; + result = proRespHdlr.getValueByte(valueOffset) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_COMMAND_DETAILS ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)2 ; + result = proRespHdlr.getValueByte(valueOffset) ; + + bRes = (result == (byte)0x00) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_DEVICE_IDENTITIES ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)0 ; + result = proRespHdlr.getValueByte(valueOffset) ; + + bRes = (result == (byte)0x82) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)0x7E ; + result = proRespHdlr.getValueByte(valueOffset) ; + + bRes = (result == (byte)0x7E) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Search Command Details TLV + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)0x7E ; + result = proRespHdlr.getValueByte(valueOffset) ; + + bRes = (result == (byte)0x7E) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Get value + valueOffset = (short)0x7F ; + result = proRespHdlr.getValueByte(valueOffset) ; + + bRes = (result == (byte)0x7F) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + // Get value + valueOffset = (short)0xEF ; + result = proRespHdlr.getValueByte(valueOffset) ; + + bRes = (result == (byte)0xEF) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/Test_Api_2_Prh_Gvby.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/Test_Api_2_Prh_Gvby.java new file mode 100644 index 0000000000000000000000000000000000000000..5b5a50acfaad626e336d181daf630859d8e71eb2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/Test_Api_2_Prh_Gvby.java @@ -0,0 +1,147 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gvby.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gvby; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gvby + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gvby extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gvby"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gvby() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9116"); + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text String Length = 7Eh) + response = test.terminalResponse("81030123 00020282 81030100 0D7F0801" + + "02030405 06070809 0A0B0C0D 0E0F1011" + + "12131415 16171819 1A1B1C1D 1E1F2021" + + "22232425 26272829 2A2B2C2D 2E2F3031" + + "32333435 36373839 3A3B3C3D 3E3F4041" + + "42434445 46474849 4A4B4C4D 4E4F5051" + + "52535455 56575859 5A5B5C5D 5E5F6061" + + "62636465 66676869 6A6B6C6D 6E6F7071" + + "72737475 76777879 7A7B7C7D 7E"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 6 to 8 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text String Length = EFh) + response = test.terminalResponse("81030123 00020282 81030100 0D81F004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0" + + "D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0" + + "E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEF"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..f21a8d0ec838c485c4ae398ad96a00893e17bc93 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gvby.Api_2_Prh_Gvby_1 +uicc.test.toolkit.api_2_prh_gvby +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/javacard/api_2_prh_gvby.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/javacard/api_2_prh_gvby.cap new file mode 100644 index 0000000000000000000000000000000000000000..3a8879702972e0de9d18a83e165ab9424712fa71 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvby/javacard/api_2_prh_gvby.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/Api_2_Prh_Gvle_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/Api_2_Prh_Gvle_1.java new file mode 100644 index 0000000000000000000000000000000000000000..5704a7201cb4e8558b410f82192d4575eb6a0306 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/Api_2_Prh_Gvle_1.java @@ -0,0 +1,230 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gvle_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gvle; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gvle + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gvle_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + + public final byte DCS_8_BIT_DATA = (byte)0x04; + /** + * Constructor of the applet + */ + public Api_2_Prh_Gvle_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gvle_1 thisApplet = new Api_2_Prh_Gvle_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + ProactiveResponseHandler proRespHdlr = null ; + + // Result of method + short result = 0 ; + + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + proRespHdlr.getValueLength() ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Successful call + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Search Text String TLV + proRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + // Get length + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Search Text String TLV + proRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + // Get length + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)2) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Search Text String TLV + proRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + // Get length + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x7F) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Search Text String TLV + proRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + // Get length + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0x80) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Search Text String TLV + proRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) ; + + // Get length + result = proRespHdlr.getValueLength() ; + + bRes = (result == (short)0xF0) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/Test_Api_2_Prh_Gvle.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/Test_Api_2_Prh_Gvle.java new file mode 100644 index 0000000000000000000000000000000000000000..8a5af7104cdef223e17985df2c571c3d610fe65c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/Test_Api_2_Prh_Gvle.java @@ -0,0 +1,194 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_PRh_Gvle.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gvle; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gvle + * + * @version 0.0.1 - 24 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gvle extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gvle"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gvle() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 & 2 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9116"); + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Null Text String) + response = test.terminalResponse("81030123 00020282 81030100 0D00"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 3 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text String Length = 01h) + response = test.terminalResponse("81030123 00020282 81030100 0D020441"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 4 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text String Length = 7Eh) + response = test.terminalResponse("81030123 00020282 81030100 0D7F0801" + + "02030405 06070809 0A0B0C0D 0E0F1011" + + "12131415 16171819 1A1B1C1D 1E1F2021" + + "22232425 26272829 2A2B2C2D 2E2F3031" + + "32333435 36373839 3A3B3C3D 3E3F4041" + + "42434445 46474849 4A4B4C4D 4E4F5051" + + "52535455 56575859 5A5B5C5D 5E5F6061" + + "62636465 66676869 6A6B6C6D 6E6F7071" + + "72737475 76777879 7A7B7C7D 7E"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 5 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text String Length = 7Fh) + response = test.terminalResponse("81030123 00020282 81030100 0D818004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 6 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + + // Terminal response (Text String Length = EFh) + response = test.terminalResponse("81030123 00020282 81030100 0D81F004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0" + + "D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0" + + "E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEF"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "06CCCCCC CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..be7f3b44acdb5cfb8d65be0dd7b97418784183cd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gvle.Api_2_Prh_Gvle_1 +uicc.test.toolkit.api_2_prh_gvle +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/javacard/api_2_prh_gvle.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/javacard/api_2_prh_gvle.cap new file mode 100644 index 0000000000000000000000000000000000000000..968f2d1ed78231f9c7448d9f266633cd8748126a Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvle/javacard/api_2_prh_gvle.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/Api_2_Prh_Gvsh_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/Api_2_Prh_Gvsh_1.java new file mode 100644 index 0000000000000000000000000000000000000000..971c1ff6becda3601c5d97f16d688db07beab8a0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/Api_2_Prh_Gvsh_1.java @@ -0,0 +1,270 @@ +//----------------------------------------------------------------------------- +//Api_2_Prh_Gvsh_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gvsh; + +import uicc.test.util.*; +import uicc.toolkit.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gvsh + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prh_Gvsh_1 extends TestToolkitApplet +{ + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] TEXT = {(byte)'T',(byte)'e',(byte)'x',(byte)'t'} ; + private static final byte DCS_8_BIT_DATA = (byte)0x04; + + /** + * Constructor of the applet + */ + public Api_2_Prh_Gvsh_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prh_Gvsh_1 thisApplet = new Api_2_Prh_Gvsh_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + public void processToolkit(short event) + { + + // Get the system instance of the ProactiveHandler class + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + + ProactiveResponseHandler proRespHdlr = null ; + + // Result of method + short result = 0 ; + short valueOffset = 0 ; + byte tag = 0 ; + byte occurence = 0 ; + + // -------------------------------------------- + // Test Case 1 : Unavailable Element + testCaseNb = (byte) 1 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + try { + valueOffset = (short)0 ; + proHdlr.getValueShort(valueOffset) ; + + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.UNAVAILABLE_ELEMENT) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 2 : Out of Tlv Boundaries + testCaseNb = (byte) 2 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_COMMAND_DETAILS ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + try { + valueOffset = (short)3 ; + result = proRespHdlr.getValueShort(valueOffset) ; + } catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.OUT_OF_TLV_BOUNDARIES) ; + } + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 3 : Successful call + testCaseNb = (byte) 3 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_COMMAND_DETAILS ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)1 ; + result = proRespHdlr.getValueShort(valueOffset) ; + + bRes = (result == (short)0x2300) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 4 : Successful call + testCaseNb = (byte) 4 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_DEVICE_IDENTITIES ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)0 ; + result = proRespHdlr.getValueShort(valueOffset) ; + + bRes = (result == (short)0x8281) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 5 : Successful call + testCaseNb = (byte) 5 ; + bRes = false ; + + try { + + // Search Command Details TLV + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)0x7D ; + result = proRespHdlr.getValueShort(valueOffset) ; + + bRes = (result == (short)0x7D7E) ; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 6 : Successful call + testCaseNb = (byte) 6 ; + bRes = false ; + + try { + + // Build and send a PRO command + proHdlr.initGetInput((byte)0, DCS_8_BIT_DATA, TEXT, (short)0, (short)TEXT.length, (short)0, (short)0xFF) ; + proHdlr.send() ; + + // Get the response + proRespHdlr = ProactiveResponseHandlerSystem.getTheHandler() ; + + // Search Command Details TLV + tag = TAG_TEXT_STRING ; + occurence = (byte)1 ; + proRespHdlr.findTLV(tag, occurence) ; + + // Get value + valueOffset = (short)0x7D ; + result = proRespHdlr.getValueShort(valueOffset) ; + + bRes = (result == (short)0x7D7E) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 7 : Successful call + testCaseNb = (byte) 7 ; + bRes = false ; + + try { + + // Get value + valueOffset = (short)0x7F ; + result = proRespHdlr.getValueShort(valueOffset) ; + + bRes = (result == (short)0x7F80) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + + // -------------------------------------------- + // Test Case 8 : Successful call + testCaseNb = (byte) 8 ; + bRes = false ; + + try { + + // Get value + valueOffset = (short)0xEE ; + result = proRespHdlr.getValueShort(valueOffset) ; + + bRes = (result == (short)0xEEEF) ; + + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/Test_Api_2_Prh_Gvsh.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/Test_Api_2_Prh_Gvsh.java new file mode 100644 index 0000000000000000000000000000000000000000..4a4572be332ae77008ded265f8d7700ede475b7c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/Test_Api_2_Prh_Gvsh.java @@ -0,0 +1,145 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prh_Gvsh.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prh_gvsh; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +/** + * Test Area : uicc.test.toolkit.api_2_prh_gvsh + * + * @version 0.0.1 - 27 juin 2005 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prh_Gvsh extends UiccTestModel +{ + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prh_gvsh"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Prh_Gvsh() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 0 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "01" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Testcase 1 to 5 */ + /*********************************************************************/ + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9116"); + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal Response (Text String length = 7Eh) + response = test.terminalResponse("81030123 00020282 81030100 0D7F0401" + + "02030405 06070809 0A0B0C0D 0E0F1011" + + "12131415 16171819 1A1B1C1D 1E1F2021" + + "22232425 26272829 2A2B2C2D 2E2F3031" + + "32333435 36373839 3A3B3C3D 3E3F4041" + + "42434445 46474849 4A4B4C4D 4E4F5051" + + "52535455 56575859 5A5B5C5D 5E5F6061" + + "62636465 66676869 6A6B6C6D 6E6F7071" + + "72737475 76777879 7A7B7C7D 7E"); + result &= response.checkSw("9116"); + + /*********************************************************************/ + /** Testcase 6 to 8 */ + /*********************************************************************/ + + // Fetch the GET INPUT proactive command + response = test.fetch("16"); + result &= response.checkData("D0148103 01230082 0281828D 05045465" + + "78749102 00FF"); + // Terminal Response (Text String length = EFh) + response = test.terminalResponse("81030123 00020282 81030100 0D81F004" + + "01020304 05060708 090A0B0C 0D0E0F10" + + "11121314 15161718 191A1B1C 1D1E1F20" + + "21222324 25262728 292A2B2C 2D2E2F30" + + "31323334 35363738 393A3B3C 3D3E3F40" + + "41424344 45464748 494A4B4C 4D4E4F50" + + "51525354 55565758 595A5B5C 5D5E5F60" + + "61626364 65666768 696A6B6C 6D6E6F70" + + "71727374 75767778 797A7B7C 7D7E7F80" + + "81828384 85868788 898A8B8C 8D8E8F90" + + "91929394 95969798 999A9B9C 9D9E9FA0" + + "A1A2A3A4 A5A6A7A8 A9AAABAC ADAEAFB0" + + "B1B2B3B4 B5B6B7B8 B9BABBBC BDBEBFC0" + + "C1C2C3C4 C5C6C7C8 C9CACBCC CDCECFD0" + + "D1D2D3D4 D5D6D7D8 D9DADBDC DDDEDFE0" + + "E1E2E3E4 E5E6E7E8 E9EAEBEC EDEEEF"); + result &= response.checkSw("9000"); + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "08CCCCCC CCCCCCCC CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..a5c456948f2c3b5b0b29047feedd501c8b9ab3b8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prh_gvsh.Api_2_Prh_Gvsh_1 +uicc.test.toolkit.api_2_prh_gvsh +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/javacard/api_2_prh_gvsh.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/javacard/api_2_prh_gvsh.cap new file mode 100644 index 0000000000000000000000000000000000000000..82a09a8cbcb23c1f2fb3411fc08e0996e7df0c36 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prh_gvsh/javacard/api_2_prh_gvsh.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/Api_2_Prs_Gthd_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/Api_2_Prs_Gthd_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3a0aeff73ff4905093d036dac8aa9ba82077db0b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/Api_2_Prs_Gthd_1.java @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------------- +//Api_2_Prs_Gthd_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prs_gthd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import uicc.test.util.TestToolkitApplet; +import uicc.toolkit.ProactiveResponseHandler; +import uicc.toolkit.ProactiveResponseHandlerSystem; + +/** + * Test Area : uicc.test.toolkit.api_2_prs_gthd + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Api_2_Prs_Gthd_1 extends TestToolkitApplet +{ + + // Number of tests + byte testCaseNb = (byte) 0x00 ; + + /** + * Constructor of the applet + */ + public Api_2_Prs_Gthd_1() + { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Prs_Gthd_1 thisApplet = new Api_2_Prs_Gthd_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register on UNRECOGNIZED ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the SIM Toolkit Framework + */ + public void processToolkit(short event) + { + // Result of tests + boolean bRes ; + + switch ( testCaseNb ) + { + case (byte) 0 : + // -------------------------------------------- + // Test Case 1 : use th methode getTheHandler() Twice + testCaseNb = (byte) 1 ; + + bRes = false ; + try { + ProactiveResponseHandler ProRespHdlr1 = ProactiveResponseHandlerSystem.getTheHandler(); + ProactiveResponseHandler ProRespHdlr2 = ProactiveResponseHandlerSystem.getTheHandler(); + + if (ProRespHdlr1==ProRespHdlr2 ) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 1 : + // -------------------------------------------- + // Test Case 2 : verify that the methode getTheHandler return ProactiveResponseHandler reference + testCaseNb = (byte) 2 ; + + bRes = false ; + try { + ProactiveResponseHandler ProRespHdlr1 = ProactiveResponseHandlerSystem.getTheHandler(); + + if (ProRespHdlr1 instanceof ProactiveResponseHandler) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 2 : + // -------------------------------------------- + // Test Case 3 : verify that the methode getTheHandler does not return NULL + testCaseNb = (byte) 3 ; + + bRes = false ; + try { + ProactiveResponseHandler ProRespHdlr1 = ProactiveResponseHandlerSystem.getTheHandler(); + + if (ProRespHdlr1!=null) + bRes = true; + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + break; + } + } +} + + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/Test_Api_2_Prs_Gthd.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/Test_Api_2_Prs_Gthd.java new file mode 100644 index 0000000000000000000000000000000000000000..96de14d1d364904122b8302c9dbcffab74ae5d63 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/Test_Api_2_Prs_Gthd.java @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +//Test_Api_2_Prs_Gthd.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_prs_gthd; +//----------------------------------------------------------------------------- +//Imports +//----------------------------------------------------------------------------- + +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; + +/** + * Test Area : uicc.test.toolkit.api_2_prs_gthd + * + * @version 0.0.1 - 3 mars 2006 + * @author 3GPP T3 SWG API + */ +public class Test_Api_2_Prs_Gthd extends UiccTestModel +{ + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_prs_gthd"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Prs_Gthd() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + /*********************************************************************/ + /** Applet installation */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + + /*********************************************************************/ + /** Testcase 1 to 3 */ + /*********************************************************************/ + + // Card Initialisation + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + // Test cases 1,2,3 + for (byte i = 0; i < 3; i++) + { + response = test.unrecognizedEnvelope(); + } + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applets */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + + "03CCCCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Restore card */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + // delete applets and package + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..394289f86ca23e8ed697b2edd82681864cfd2463 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_prs_gthd.Api_2_Prs_Gthd_1 +uicc.test.toolkit.api_2_prs_gthd +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/javacard/api_2_prs_gthd.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/javacard/api_2_prs_gthd.cap new file mode 100644 index 0000000000000000000000000000000000000000..bf2c29000c6a3bba6ae89c98f0246d904003c2fa Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_prs_gthd/javacard/api_2_prs_gthd.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/Api_2_Tep_Chec_Bss_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/Api_2_Tep_Chec_Bss_1.java new file mode 100644 index 0000000000000000000000000000000000000000..3dad6eea2bfc9d8408c0ea322d930ed9c5b8966a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/Api_2_Tep_Chec_Bss_1.java @@ -0,0 +1,226 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_chec_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, TerminalProfile class, check(byte[], short, short) method + * applet 1 + */ +public class Api_2_Tep_Chec_Bss_1 extends TestToolkitApplet { + + private static final byte[] COMPARE = {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xA9, + (byte)0x77}; + + /** + * Constructor of the applet + */ + public Api_2_Tep_Chec_Bss_1() { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tep_Chec_Bss_1 thisApplet = new Api_2_Tep_Chec_Bss_1(); + + // Register the new applet instance to the JCRE. + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // Register to unrecognized envelope + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + byte testCaseNb = (byte)0x00 ; + // Result of tests + boolean bRes = false; + + if (event == EVENT_STATUS_COMMAND) { + /** Test Case 1: ToolkitException ME_PROFILE_NOT_AVAILABLE is sent */ + testCaseNb = (byte)1; + bRes = false; + + try { + TerminalProfile.check(COMPARE, (short)0, (short)16); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.TERMINAL_PROFILE_NOT_AVAILABLE); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /** Test Case 2: NULL as parameter to check */ + testCaseNb = (byte)2; + bRes = false; + + try { + TerminalProfile.check(null, (short)0, (short)1); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 3: Offset > COMPARE.length */ + testCaseNb = (byte)3; + bRes = false; + + try { + TerminalProfile.check(COMPARE, (short)17, (short)1); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 4: Offset < 0 */ + testCaseNb = (byte)4; + bRes = false; + + try { + TerminalProfile.check(COMPARE, (short)-1, (short)1); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 5: Length > COMPARE.length */ + testCaseNb = (byte)5; + bRes = false; + + try { + TerminalProfile.check(COMPARE, (short)0, (short)18); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 6: Offset+Length > COMPARE.length */ + testCaseNb = (byte)6; + bRes = false; + + try { + TerminalProfile.check(COMPARE, (short)9, (short)9); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 7: length < 0 */ + testCaseNb = (byte)7; + bRes = false; + + try { + TerminalProfile.check(COMPARE, (short)0, (short)-1); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 8: length = 0 */ + testCaseNb = (byte)8; + bRes = false; + + try { + bRes = TerminalProfile.check(COMPARE, (short)0, (short)0); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 9: Check all the Terminal Profile */ + testCaseNb = (byte)9; + bRes = false; + + try { + if (TerminalProfile.check(COMPARE, (short)0, (short)16) == false) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 10: Check 2 first bytes of the Terminal Profile */ + testCaseNb = (byte)10; + bRes = false; + + try { + bRes = TerminalProfile.check(COMPARE,(short)15, (short)2); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 11: Check facility 15 of the Terminal Profile */ + testCaseNb = (byte)11; + bRes = false; + byte[] COMPARE2 = {(byte)0x00,(byte)0x80}; + + try { + if (TerminalProfile.check(COMPARE2, (short)0, (short)2) == false) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/Test_Api_2_Tep_Chec_Bss.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/Test_Api_2_Tep_Chec_Bss.java new file mode 100644 index 0000000000000000000000000000000000000000..971f2f49bc0357be7bd8275bbf6435b622c575be --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/Test_Api_2_Tep_Chec_Bss.java @@ -0,0 +1,79 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for TerminalProfile class + * check(byte[], short, short) method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_chec_bss; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tep_Chec_Bss extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tep_chec_bss"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tep_Chec_Bss() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + + // test case 1: send a status command to trigger the applet without terminal profile + test.status("00","00","04"); + + // test case 2 to 11 + test.reset(); + test.terminalProfileSession("A977FFF1 FFFFFFFF FFFFFFFF FFFFFFFF"); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0BCCCCCC CCCCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d2987eca7fe81f70f062748f5833ea8aac344dce --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tep_chec_bss.Api_2_Tep_Chec_Bss_1 +uicc.test.toolkit.api_2_tep_chec_bss +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/javacard/api_2_tep_chec_bss.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/javacard/api_2_tep_chec_bss.cap new file mode 100644 index 0000000000000000000000000000000000000000..f373cc3c7421d5102212a3fdb0d2104cc28f7e89 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_chec_bss/javacard/api_2_tep_chec_bss.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/Api_2_Tep_Checb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/Api_2_Tep_Checb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..dcca2718f3088b3a0f92e5b91cf1bf7a07323c37 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/Api_2_Tep_Checb_1.java @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_checb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, TerminalProfile class, check(byte) method + * applet 1 + */ +public class Api_2_Tep_Checb_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Tep_Checb_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tep_Checb_1 thisApplet = new Api_2_Tep_Checb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_STATUS_COMMAND and EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + // Result of tests + boolean bRes = false; + + if (event == EVENT_STATUS_COMMAND) { + /** Test Case 1: ToolkitException TERMINAL_PROFILE_NOT_AVAILABLE is sent */ + testCaseNb = (byte) 1; + bRes = false; + try { + TerminalProfile.check((byte)1); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.TERMINAL_PROFILE_NOT_AVAILABLE); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + /** Test Case 2: Facility is supported */ + testCaseNb = (byte)2; + bRes = false; + try { + bRes = TerminalProfile.check((byte)0); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 3: Facility is not supported */ + testCaseNb = (byte)3; + bRes = false; + + try { + if (TerminalProfile.check((byte)15) == false) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 4: Facility index is outside TerminalProfile data */ + testCaseNb = (byte)4; + bRes = false; + + try { + if (TerminalProfile.check((byte)0x7F) == false) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes =false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 5: ToolkitException BAD_INPUT_PARAMETER is sent */ + testCaseNb = (byte)5; + bRes = false; + try { + TerminalProfile.check((byte)0x80); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/Test_Api_2_Tep_Checb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/Test_Api_2_Tep_Checb.java new file mode 100644 index 0000000000000000000000000000000000000000..655b854f40c9a06f19627dc9d1b6fdc70a76a719 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/Test_Api_2_Tep_Checb.java @@ -0,0 +1,79 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for TerminalProfile class + * check(byte) method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_checb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tep_Checb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tep_checb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tep_Checb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + + // test case 1: send a status command to trigger the applet without terminal profile + test.status("00","00","04"); + + // test case 2 to 4 + test.reset(); + test.terminalProfileSession("010160"); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..f7f40ad6857b53c3d0447fe6e4d2c4eefee8b635 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tep_checb.Api_2_Tep_Checb_1 +uicc.test.toolkit.api_2_tep_checb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/javacard/api_2_tep_checb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/javacard/api_2_tep_checb.cap new file mode 100644 index 0000000000000000000000000000000000000000..ad978bce7efcc8f4d3fc13375a338ab9c97863d6 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checb/javacard/api_2_tep_checb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/Api_2_Tep_Checs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/Api_2_Tep_Checs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7d065cfa59510aeb9ef20f2c7c9f05d39f77506b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/Api_2_Tep_Checs_1.java @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_checs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, TerminalProfile class, check(short) method + * applet 1 + */ +public class Api_2_Tep_Checs_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Tep_Checs_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tep_Checs_1 thisApplet = new Api_2_Tep_Checs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_STATUS_COMMAND and EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + // Result of tests + boolean bRes = false; + + if (event == EVENT_STATUS_COMMAND) { + /** Test Case 1: ToolkitException TERMINAL_PROFILE_NOT_AVAILABLE is sent */ + testCaseNb = (byte) 1; + bRes = false; + try { + TerminalProfile.check((short)1); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.TERMINAL_PROFILE_NOT_AVAILABLE); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + /** Test Case 2: Facility is supported */ + testCaseNb = (byte)2; + bRes = false; + try { + bRes = TerminalProfile.check((short)0); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 3: Facility is not supported */ + testCaseNb = (byte)3; + bRes = false; + + try { + if (TerminalProfile.check((short)15) == false) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 4: Facility index is outside TerminalProfile data */ + testCaseNb = (byte)4; + bRes = false; + + try { + if (TerminalProfile.check((short)0x0099) == false) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes =false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 5: ToolkitException BAD_INPUT_PARAMETER is sent */ + testCaseNb = (byte)5; + bRes = false; + try { + TerminalProfile.check((short)0x8000); + } + catch (ToolkitException e) { + if (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) { + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/Test_Api_2_Tep_Checs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/Test_Api_2_Tep_Checs.java new file mode 100644 index 0000000000000000000000000000000000000000..0c39a325c430cda5e66340887acf83b1f65d0315 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/Test_Api_2_Tep_Checs.java @@ -0,0 +1,78 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for TerminalProfile class + * check(short) method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_checs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tep_Checs extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tep_checs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tep_Checs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + + // test case 1: send a status command to trigger the applet without terminal profile + test.status("00","00","04"); + + // test case 2 to 4 + test.reset(); + test.terminalProfileSession("010160"); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..12bb1061d4a881e5341eb9a9b9d4cbc1ae6b39cb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tep_checs.Api_2_Tep_Checs_1 +uicc.test.toolkit.api_2_tep_checs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/javacard/api_2_tep_checs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/javacard/api_2_tep_checs.cap new file mode 100644 index 0000000000000000000000000000000000000000..101de1ac6dbbdec979ba2597ffa3a119c9843901 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_checs/javacard/api_2_tep_checs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_copy/Api_2_Tep_Copy_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_copy/Api_2_Tep_Copy_1.java new file mode 100644 index 0000000000000000000000000000000000000000..0ccf79ff4d026ed26073bc08779c41cbba22a9b7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_copy/Api_2_Tep_Copy_1.java @@ -0,0 +1,299 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_copy; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, TerminalProfile class, copy() method + * applet 1 + */ +public class Api_2_Tep_Copy_1 extends TestToolkitApplet { + + // Number of tests + byte testCaseNb = (byte) 0x00; + + private byte[] nullBuffer; + private byte[] dstBuffer = new byte[5]; + + /** + * Constructor of the applet + */ + public Api_2_Tep_Copy_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Api_2_Tep_Copy_1 thisApplet = new Api_2_Tep_Copy_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_STATUS_COMMAND and EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.requestPollInterval(POLL_SYSTEM_DURATION); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + // Result of tests + boolean bRes; + byte index; + + if (event == EVENT_STATUS_COMMAND) { + /** Test Case 1: ToolkitException TERMINAL_PROFILE_NOT_AVAILABLE is sent */ + testCaseNb = (byte) 1; + bRes = false; + try { + TerminalProfile.copy((short)0, dstBuffer, (short)0, (short)2); + } + catch (ToolkitException e) { + if (isBufferEmpty(dstBuffer)) + bRes = (e.getReason() == ToolkitException.TERMINAL_PROFILE_NOT_AVAILABLE); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + /** Test Case 2: Null buffer */ + testCaseNb = (byte)2; + bRes = false; + try { + TerminalProfile.copy((short)0, nullBuffer, (short)0, (short)4); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 3: dstOffset >= dstBuffer.length */ + testCaseNb = (byte)3; + bRes = false; + try { + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0); + TerminalProfile.copy((short)0, dstBuffer, (short)5, (short)1); + } + catch (ArrayIndexOutOfBoundsException e) { + if (isBufferEmpty(dstBuffer)) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 4: dstOffset < 0 */ + testCaseNb = (byte)4; + bRes = false; + try { + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short) dstBuffer.length, (byte)0); + TerminalProfile.copy((short)0, dstBuffer, (short)-1, (short)1); + } + catch (ArrayIndexOutOfBoundsException e) { + if (isBufferEmpty(dstBuffer)) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 5: dstLength < 0 */ + testCaseNb = (byte)5; + bRes = false; + try { + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0); + TerminalProfile.copy((short)0, dstBuffer, (short)0, (short)-1); + } + catch (ArrayIndexOutOfBoundsException e) { + if (isBufferEmpty(dstBuffer)) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 6: dstLength > dstBuffer.length */ + testCaseNb = (byte)6; + bRes = false; + try { + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0); + TerminalProfile.copy((short)0, dstBuffer, (short)0, (short)6); + } + catch (ArrayIndexOutOfBoundsException e) { + if (isBufferEmpty(dstBuffer)) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 7: dstOffset + dstLength > dstBuffer.length */ + testCaseNb = (byte)7; + bRes = false; + try { + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0); + TerminalProfile.copy((short)0, dstBuffer, (short)3, (short)3); + } + catch (ArrayIndexOutOfBoundsException e) { + if (isBufferEmpty(dstBuffer)) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 8: Successful call */ + testCaseNb = (byte)8; + bRes = false; + try { + dstBuffer = new byte[6]; + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short) dstBuffer.length, (byte)0x55); + + if (TerminalProfile.copy((short)0, dstBuffer, (short)0, (short)6) == (short)6) { + if ( ( (dstBuffer[0]&(byte)0xFD) == (byte) 0xA9) + && ( dstBuffer[1] == (byte) 0x01) + && ( dstBuffer[2] == (byte) 0xD2) + && ( dstBuffer[3] == (byte) 0xF0) + && ( dstBuffer[4] == (byte) 0x01) + && ( dstBuffer[5] == (byte) 0x02) + ) { + bRes = true; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 9: Successful call */ + testCaseNb = (byte)9; + bRes = false; + try { + dstBuffer = new byte[20]; + + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0x55); + + if (TerminalProfile.copy((short)1, dstBuffer, (short)3, (short)4) == (short)7) { + if ( ( dstBuffer[3] == (byte) 0x01) + && ( dstBuffer[4] == (byte) 0xD2) + && ( dstBuffer[5] == (byte) 0xF0) + && ( dstBuffer[6] == (byte) 0x01) + ) { + bRes = true; + + for (index = 0; (index < 3)&&bRes; index++) { + bRes = ( dstBuffer[index] == (byte) 0x55 ); + } + for (index = 7; (index < dstBuffer.length)&&bRes; index++) { + bRes = ( dstBuffer[index] == (byte) 0x55 ); + } + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 10: Successful call, copy with length =0 */ + testCaseNb = (byte)10; + bRes = false; + try { + dstBuffer = new byte[20]; + + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0x55); + + if (TerminalProfile.copy((short)0, dstBuffer, (short)20, (short)0) == (short)20) { + bRes = true; + + for (index = 0; (index < dstBuffer.length)&&bRes; index++) { + bRes = (dstBuffer[index] == (byte) 0x55); + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 11: Value outside MEProfile data available */ + testCaseNb = (byte)11; + bRes = false; + try { + dstBuffer = new byte[6]; + + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0x55); + + if (TerminalProfile.copy((short)13, dstBuffer, (short)0, (short)6) == (short)6) { + if ( ( dstBuffer[0] == (byte) 0x8D) + && ( dstBuffer[1] == (byte) 0xFF) + && ( dstBuffer[2] == (byte) 0x00) + && ( dstBuffer[3] == (byte) 0x00) + && ( dstBuffer[4] == (byte) 0x00) + && ( dstBuffer[5] == (byte) 0x00) + ) { + bRes = true; + } + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 12: startOffset < 0 */ + testCaseNb = (byte)12; + bRes = false; + try { + Util.arrayFillNonAtomic(dstBuffer, (short)0, (short)dstBuffer.length, (byte)0); + TerminalProfile.copy((short)-1, dstBuffer, (short)0, (short)6); + } + catch (ToolkitException e) { + if (isBufferEmpty(dstBuffer)) + if (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER) + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } + + boolean isBufferEmpty(byte[] buf) { + for ( byte i = 0; i indexLSB + 16 */ + testCaseNb = (byte) 7; + bRes = false; + try { + TerminalProfile.getValue((short)0x0021, (short)0x0010); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 8: indexMSB = indexLSB + 16 */ + testCaseNb = (byte) 8; + bRes = false; + try { + TerminalProfile.getValue((short)0x0020, (short)0x0010); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + /** Test Case 9: indexMSB is outside data available */ + testCaseNb = (byte)9; + bRes = false; + + try { + bRes = (TerminalProfile.getValue((short)121, (short)115) == (short)0x001F); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/Test_Api_2_Tep_Gval.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/Test_Api_2_Tep_Gval.java new file mode 100644 index 0000000000000000000000000000000000000000..dea080f977274094f004af9676e50283d170de35 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/Test_Api_2_Tep_Gval.java @@ -0,0 +1,79 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for TerminalProfile class + * getValue() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tep_gval; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tep_Gval extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tep_gval"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tep_Gval() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + + // test case 1: send a status command to trigger the applet without terminal profile + test.status("00","00","04"); + + // test case 2 to 9 + test.reset(); + test.terminalProfileSession("A901D2F0 00000000 00000000 008DFF"); + + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "09CCCCCC CCCCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..7383d9c3bd01e5590ccdc74b5ba61939e4f05912 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tep_gval.Api_2_Tep_Gval_1 +uicc.test.toolkit.api_2_tep_gval +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/javacard/api_2_tep_gval.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/javacard/api_2_tep_gval.cap new file mode 100644 index 0000000000000000000000000000000000000000..403c805ee107bb119d2327acb3fe2fa8f293adf3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tep_gval/javacard/api_2_tep_gval.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/Api_2_Tke_Coor_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/Api_2_Tke_Coor_1.java new file mode 100644 index 0000000000000000000000000000000000000000..de842bf6e61f78ec127b537a7de62ee01f71684d --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/Api_2_Tke_Coor_1.java @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------------- +//Api_4_Aex_Coor_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tke_coor; + +import uicc.test.util.* ; +import uicc.toolkit.*; + + +public class Api_2_Tke_Coor_1 extends TestToolkitApplet +{ + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Tke_Coor_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_2_Tke_Coor_1 thisApplet = new Api_2_Tke_Coor_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false,(byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + boolean bRes = false; + byte testCaseNb = (byte)0; + + /** Test Case 1 : ToolkitException with the specified set reason */ + testCaseNb = (byte)1; + bRes = false ; + ToolkitException ToolEx = new ToolkitException((short)19); + bRes = (ToolEx.getReason() == (short)19); + + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/Test_Api_2_Tke_Coor.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/Test_Api_2_Tke_Coor.java new file mode 100644 index 0000000000000000000000000000000000000000..ed43297a6dad21adcc3c8152058c62b688793cb9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/Test_Api_2_Tke_Coor.java @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tke_coor; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_2_Tke_Coor extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tke_coor"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Tke_Coor() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "01" + "CC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..265b2f628dde51a5282c8f862689d5c0eec1a574 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tke_coor.Api_2_Tke_Coor_1 +uicc.test.toolkit.api_2_tke_coor +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/javacard/api_2_tke_coor.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/javacard/api_2_tke_coor.cap new file mode 100644 index 0000000000000000000000000000000000000000..ab42b7d93f9f99d67449abc5259ad1e735d2309c Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_coor/javacard/api_2_tke_coor.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/Api_2_Tke_Thit_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/Api_2_Tke_Thit_1.java new file mode 100644 index 0000000000000000000000000000000000000000..79c4d040b6ecaeb93f4578bc86cb6bb86a60bed7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/Api_2_Tke_Thit_1.java @@ -0,0 +1,149 @@ +//----------------------------------------------------------------------------- +//Api_4_Aex_Thit_1.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +//Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tke_thit; + +import uicc.test.util.* ; +import uicc.toolkit.*; +import javacard.framework.* ; + + +public class Api_2_Tke_Thit_1 extends TestToolkitApplet +{ + private static byte[] MenuInit = {(byte)'M',(byte)'e',(byte)'n',(byte)'u',(byte)'1'}; + byte testCaseNb = (byte) 0x00; + + /** + * Constructor of the applet + */ + public Api_2_Tke_Thit_1() + { + } + + /** + * Method called by the JCRE at the installation of the applet. + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance. + Api_2_Tke_Thit_1 thisApplet = new Api_2_Tke_Thit_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet. + thisApplet.init(); + + // toolkit registration + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0,(short) MenuInit.length, (byte) 0, false,(byte) 0, (short) 0); + } + + /** + * Method called by the Cat Re + */ + public void processToolkit(short event) + { + // Number of tests + byte testCaseNb = (byte)0; + // Result of tests + boolean bRes = false; + + /** Test Case 1 : Throws the JCRE instance of ToolkitException with the specified reason 0 */ + testCaseNb = (byte)1; + bRes = false ; + try { + ToolkitException.throwIt((short) 0); + } + catch (ToolkitException ToolEx) { + bRes= (ToolEx.getReason() == (short)0); + } + catch( Exception e ) { + // Error, throw not as a ToolkitException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 2 : Throws the JCRE instance of ToolkitException with the specified reason 1*/ + testCaseNb = (byte)2; + bRes = false ; + + try { + ToolkitException.throwIt((short) 1); + } + catch (ToolkitException ToolEx) { + bRes = (ToolEx.getReason() == (short)1 ); + } + catch( Exception e ) { + // Error, throw not as a ToolkitException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 3 : Throws the JCRE instance of ToolkitException with the specified reason 0xA55A*/ + testCaseNb = (byte)3; + bRes = false ; + + try { + ToolkitException.throwIt((short) 0xA55A); + } + catch (ToolkitException ToolEx) { + bRes = (ToolEx.getReason() == (short)0xA55A ); + } + catch( Exception e ) { + // Error, throw not as a ToolkitException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 4 : ToolkitException extends javacard.framework.CardRuntimeException reason 0*/ + testCaseNb = (byte)4; + bRes = false ; + + try { + ToolkitException.throwIt((short) 0); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)0 ); + } + catch( Exception e ) { + // Error, throw not as a ToolkitException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 5 : ToolkitException extends javacard.framework.CardRuntimeException reason 1*/ + testCaseNb = (byte)5; + bRes = false ; + + try { + ToolkitException.throwIt((short) 1); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)1 ); + } + catch( Exception e ) { + // Error, throw not as a ToolkitException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + + /** Test Case 6 : ToolkitException extends javacard.framework.CardRuntimeException reason 0xA55A*/ + testCaseNb = (byte)6; + bRes = false ; + + try { + ToolkitException.throwIt((short) 0xA55A); + } + catch (CardRuntimeException CardEx) { + bRes = (CardEx.getReason() == (short)0xA55A ); + } + catch( Exception e ) { + // Error, throw not as a ToolkitException + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/Test_Api_2_Tke_Thit.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/Test_Api_2_Tke_Thit.java new file mode 100644 index 0000000000000000000000000000000000000000..496d235c01ffc22153aa01a216e81400ff9dfed2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/Test_Api_2_Tke_Thit.java @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tke_thit; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userinterface.*; +import org.etsi.scp.wg3.uicc.jcapi.userclass.*; + +public class Test_Api_2_Tke_Thit extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tke_thit"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + + public Test_Api_2_Tke_Thit() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + APDUResponse data = null; + boolean result = false; + + // test script + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + + + /*********************************************************************/ + /** Testcase 1-6 */ + /*********************************************************************/ + + // Install package + test.loadPackage(CAP_FILE_PATH); + // Install Applet1 + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "01" + // V Id of menu entry 1 + "01" + // V Position of menu entry 1 + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("09030120"); + + // Trigger Applet + response = test.envelopeMenuSelection("100101", ""); + result = response.checkSw("9000"); + + + /*********************************************************************/ + /*********************************************************************/ + /** Check Applet */ + /*********************************************************************/ + /*********************************************************************/ + + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "06" + "CCCCCCCC CCCC"); + + /*********************************************************************/ + /*********************************************************************/ + /** Delete Applet and package */ + /*********************************************************************/ + /*********************************************************************/ + + test.reset(); + test.terminalProfileSession(UiccCardManagementService.DEFAULT_TERMINAL_PROFILE); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..55d950a5aa09835ce5b4855e127022e28b9fdfb7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tke_thit.Api_2_Tke_Thit_1 +uicc.test.toolkit.api_2_tke_thit +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/javacard/api_2_tke_thit.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/javacard/api_2_tke_thit.cap new file mode 100644 index 0000000000000000000000000000000000000000..facc4168640543973b26c825da2b5062696b06ea Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tke_thit/javacard/api_2_tke_thit.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_1.java new file mode 100644 index 0000000000000000000000000000000000000000..868af2769c85499e889a2237f70bd184ebb893b2 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_1.java @@ -0,0 +1,213 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_asid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, allocateServiceIdentifier() method + * applet 1 + */ +public class Api_2_Tkr_Asid_1 extends TestToolkitApplet { + + private byte testCaseNb = 0; + private static boolean bRes; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'1'}; + + // Service ID value range + private static short MIN_SERVICE_ID = 0; + private static short MAX_SERVICE_ID = 7; + + // Service expiration counter + short serviceExpiration = (short)(MAX_SERVICE_ID + 1); + + // Service ID array : initially all at '8' which is not a correct Service ID + public static byte[] Services = {(byte)8,(byte)8,(byte)8,(byte)8, + (byte)8,(byte)8,(byte)8,(byte)8}; + + private static byte[] abServiceRecord = {(byte)0x00, (byte)0x00, (byte)0x00}; + + // Constructor of the applet + public Api_2_Tkr_Asid_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Asid_1 thisApplet = new Api_2_Tkr_Asid_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short)0, + (short)MenuInit.length, (byte)0, false, + (byte)0, (short)0); + } + + /** + * Method called by the processToolkit() method to know if short + * has already been added to array + */ + public static boolean isInArray(short temp, byte[] Array) { + boolean isInArray = false; + + for (byte i = 0; (i < (byte)Array.length) && (!isInArray); i++) { + isInArray = (Array[i] == temp); + } + return isInArray; + } + + /** + * Method called by the processToolkit() method to know if an ID + * belongs to the Service ID interval + */ + public static boolean isServiceID(byte ID) { + boolean isServiceID; + + isServiceID = (ID > (byte)(MIN_SERVICE_ID - 1)) && (ID < (byte)(MAX_SERVICE_ID + 1)); + return isServiceID; + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + byte temp = 0; + byte TLV; + byte ServiceID; + short i; + + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler(); + + if (event == EVENT_MENU_SELECTION) { + switch (testCaseNb) { + case (byte)0x00: + // ----------------------------------------------------------------- + // Test Case 1: Allocates up to 8 services + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = true; + + try { + for (i=(short)0; (i<(short)8) && (bRes);i++) { + temp = obReg.allocateServiceIdentifier(); + bRes = (isServiceID(temp)) && (!this.isInArray(temp,Services)); + Services[i] = temp; + + // DECLARE SERVICE proactive command + abServiceRecord[1] = temp; + proHdlr.init(PRO_CMD_DECLARE_SERVICE, (byte)0x00 /*Add*/, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_SERVICE_RECORD, abServiceRecord, (short)0x00, (short)abServiceRecord.length); + proHdlr.send(); + + bRes &= obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)0x09: + // ----------------------------------------------------------------- + // Test Case 3: Allocates up to 5 services + // ----------------------------------------------------------------- + testCaseNb = (byte)0x0A; + bRes = true; + + // re-initialize Services[] array, for comparison of service id + for (byte k = 0; k<(byte)Services.length; k++) { + Services[k] = (byte)8; + } + + // allocate 5 Service ID. Check there are not already allocated. + try { + for (i=(short)0; (i<(short)5) && (bRes);i++) { + temp = obReg.allocateServiceIdentifier(); + bRes = (isServiceID(temp)) && (!this.isInArray(temp,Services)); + Services[i] = temp; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)0x0A: + // ----------------------------------------------------------------- + // Second triggering: Release all 5 services + // ----------------------------------------------------------------- + testCaseNb = (byte)0x0B; + try { + for (i=(short)0; i<(short)5; i++) { + obReg.releaseServiceIdentifier(Services[i]); + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + } + } + + /** Test Case 2: Check applet is triggered by envelope + * (EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) command + * release all Service ID. + */ + if (event == EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) { + + //testCaseNb 0x02...0x09 + testCaseNb++; + + bRes = true; + // Get the system instance of the ProactiveHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // find Service ID + TLV = envHdlr.findTLV(TAG_SERVICE_RECORD, (byte)1); + if(TLV != TLV_NOT_FOUND){ + // get the Service ID + ServiceID = envHdlr.getValueByte((short)1); + + try { + obReg.releaseServiceIdentifier((byte)ServiceID); + } + catch (Exception e) { + bRes = false; + } + if (--serviceExpiration == 0) { + //testCaseNb 0x09 + bRes = bRes & !obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + reportTestOutcome(testCaseNb, bRes); + } else { + //testCaseNb 0x02...0x08 + reportTestOutcome(testCaseNb, bRes); + } + } else { + reportTestOutcome(testCaseNb, false); + } + + + + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_2.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_2.java new file mode 100644 index 0000000000000000000000000000000000000000..9b1fb2f31d7d64a5e5312b4ffcd26524ca8bd211 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_2.java @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_asid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * uicc.toolkit package, ToolkitRegistry interface, allocateServiceIdentifier() method + * applet 2 + */ +public class Api_2_Tkr_Asid_2 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'2'}; + + // Constructor of the applet + public Api_2_Tkr_Asid_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Asid_2 thisApplet = new Api_2_Tkr_Asid_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, (byte) 0, + false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + byte temp = 0; + short i; + + switch (testCaseNb) { + case 0: + // ----------------------------------------------------------------- + // Test Case 4: call 3 times allocateServiceIdentifier() method + // ----------------------------------------------------------------- + testCaseNb = (byte) 1; + bRes = true; + + try { + for (i=(short)5; (i<(short)8) && (bRes); i++) { + temp = obReg.allocateServiceIdentifier(); + bRes = (!Api_2_Tkr_Asid_1.isInArray(temp,Api_2_Tkr_Asid_1.Services)); + Api_2_Tkr_Asid_1.Services[i] = temp; + } + + // call 1 more allocateServiceIdentifier() method + obReg.allocateServiceIdentifier(); + bRes = false; + } + catch (ToolkitException e) { + bRes = bRes && (e.getReason() == ToolkitException.NO_SERVICE_ID_AVAILABLE); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + case 1: + // ----------------------------------------------------------------- + // Test Case 5: Allocate services more than the maximum to this applet + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + try { + obReg.allocateServiceIdentifier(); + bRes = true; + obReg.allocateServiceIdentifier(); + bRes = false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.NO_SERVICE_ID_AVAILABLE); + } + reportTestOutcome(testCaseNb, bRes); + break; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_3.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_3.java new file mode 100644 index 0000000000000000000000000000000000000000..fcf8f5da63c73df9b0b7e827a9ef81c8a9858516 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Api_2_Tkr_Asid_3.java @@ -0,0 +1,73 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_asid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * uicc.toolkit package, ToolkitRegistry interface, allocateServiceIdentifier() method + * applet 3 + */ +public class Api_2_Tkr_Asid_3 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'3'}; + + // Constructor of the applet + public Api_2_Tkr_Asid_3() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Asid_3 thisApplet = new Api_2_Tkr_Asid_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, (byte) 0, + false, (byte) 0, (short) 0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + // ----------------------------------------------------------------- + // Test Case 5: Allocate services more than the maximum to this applet + // ----------------------------------------------------------------- + testCaseNb = (byte) 1; + bRes = false; + + try { + obReg.allocateServiceIdentifier(); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.NO_SERVICE_ID_AVAILABLE); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Test_Api_2_Tkr_Asid.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Test_Api_2_Tkr_Asid.java new file mode 100644 index 0000000000000000000000000000000000000000..6ca3fad24e982dd543be584b806bd62ec9db15a5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/Test_Api_2_Tkr_Asid.java @@ -0,0 +1,159 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * allocateServiceIdentifier() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_asid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Asid extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_asid"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 20020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 20020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 20030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 20030102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Asid() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "08"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0102" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "04"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0103" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 0040"); + + // test case 1: trigger applet1 + response = test.envelopeMenuSelection("100101",""); + + // fetch 8 DECLARE SERVICE + for (int i=0; i<8 ;i++) { + char serviceID; + String check, data; + + result &= response.checkSw("9110"); + response = test.fetch("10"); + + // check that we received a ADD SERVICE command + data = response.getData(); + serviceID = data.charAt(data.lastIndexOf("4103000") + 7); + check = "D00E8103 01470082 02818241 03000X00".replace('X', serviceID); + result &= response.checkData(check); + + response = test.terminalResponse("81030147 00820282 81830100"); + } + + // test case 2: trigger applet1 with EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION event + response = test.envelopeEventDownloadLocalConnection("41030000 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030002 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030006 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030003 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030007 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030005 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030001 00"); + result &= response.checkSw("9000"); + response = test.envelopeEventDownloadLocalConnection("41030004 00"); + result &= response.checkSw("9000"); + + // test case 3: trigger applet1, applet2 then applet1 + response = test.envelopeMenuSelection("100101",""); + result &= response.checkSw("9000"); + response = test.envelopeMenuSelection("100102",""); + result &= response.checkSw("9000"); + response = test.envelopeMenuSelection("100101",""); + result &= response.checkSw("9000"); + + // test case 4: trigger applet3 then applet2 + response = test.envelopeMenuSelection("100103",""); + result &= response.checkSw("9000"); + response = test.envelopeMenuSelection("100102",""); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0BCCCCCC CCCCCCCC CCCCCCCC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "02CCCC"); + + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..9e4176eec6bbd95aea8af0e4b899db12a7580250 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x02:0x00:0x01 uicc.test.toolkit.api_2_tkr_asid.Api_2_Tkr_Asid_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x03:0x00:0x01 uicc.test.toolkit.api_2_tkr_asid.Api_2_Tkr_Asid_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_asid.Api_2_Tkr_Asid_1 +uicc.test.toolkit.api_2_tkr_asid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/javacard/api_2_tkr_asid.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/javacard/api_2_tkr_asid.cap new file mode 100644 index 0000000000000000000000000000000000000000..3d43f0c38920abeca9016036da26401a8d313942 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_asid/javacard/api_2_tkr_asid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_1.java new file mode 100644 index 0000000000000000000000000000000000000000..009167ad82ad7dc691ddb5ff57c9a06c62aecf62 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_1.java @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_atim; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, allocateTimer() method + * applet 1 + */ +public class Api_2_Tkr_Atim_1 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'1'}; + + // Timer ID value range + private static short MIN_TIMER_ID = 1; + private static short MAX_TIMER_ID = 8; + + // Timer expirations counter + short j = MAX_TIMER_ID; + + // Timer ID array : initially all at '0' which is not a correct Timer ID + short[] Timers = {(short)0,(short)0,(short)0,(short)0,(short)0, + (short)0,(short)0,(short)0}; + + // Constructor of the applet + public Api_2_Tkr_Atim_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Atim_1 thisApplet = new Api_2_Tkr_Atim_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, + (short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the processToolkit() method to know if short + * has already been added to array + */ + private boolean isInArray(short temp, short[] Array) { + boolean isInArray = false; + + for(short i = ((short) (Array.length-1)); ((i > (short) -1) && (!isInArray)); i--) { + isInArray = (Array[i] == temp); + } + return isInArray; + } + + /** + * Method called by the processToolkit() method to know if an ID + * belongs to the timer ID interval + */ + private boolean isTimerID(short ID) { + boolean isTimerID; + + isTimerID = (ID>(short)(MIN_TIMER_ID-1)) && (ID<(short)(MAX_TIMER_ID+1)); + return isTimerID; + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + short temp = 0; + short i; + + byte TLV; + byte TimerID; + + + if (event == EVENT_MENU_SELECTION) { + // ----------------------------------------------------------------- + // Test Case 1: 8 * allocateTimer() + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = true; + + try { + for (i=(short)0; (i<(short)8) && (bRes);i++) { + temp = obReg.allocateTimer(); + bRes = (isTimerID(temp)) && (!this.isInArray(temp,Timers)); + Timers[i] = temp; + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2: Max timer rushed + // The applet allocates 1 more timer + // Shall throw a ToolkitException + // with reason NO_TIMER_AVAILABLE + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + try { + temp = obReg.allocateTimer(); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.NO_TIMER_AVAILABLE); + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3: Initialiation of the test case. + // shall be set at true only if the applet is triggered + // by an 8 EVENT_TIMER_EXPIRATION + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = true; + } + + // ----------------------------------------------------------------- + // Test Case 3: Call releaseTimer(id) each time a timer expires + // ----------------------------------------------------------------- + if (event == EVENT_TIMER_EXPIRATION) { + // Get the system instance of the EnvelopeHandler class + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // find timer ID which has expired + TLV = envHdlr.findTLV(TAG_TIMER_IDENTIFIER, (byte)1); + if(TLV != TLV_NOT_FOUND){ + // get the timer ID + TimerID = envHdlr.getValueByte((short)0); + + try { + obReg.releaseTimer((byte) TimerID); + } + catch (Exception e) { + bRes = false; + } + + if (--j==0) { + reportTestOutcome(testCaseNb, bRes); + } + } else { + reportTestOutcome(testCaseNb, false); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_2.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_2.java new file mode 100644 index 0000000000000000000000000000000000000000..23192790168cb35aec8d0a6ab2d9f3d9898b59de --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_2.java @@ -0,0 +1,122 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_atim; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * uicc.toolkit package, ToolkitRegistry interface, allocateTimer() method + * applet 2 + */ +public class Api_2_Tkr_Atim_2 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'2'}; + + //Timer ID value range + private static short MIN_TIMER_ID = 1; + private static short MAX_TIMER_ID = 8; + + // Timer ID array : initially all at '0' which is not a correct Timer ID + short[] Timers = {(short)0, (short)0, (short)0, (short)0}; + + // Constructor of the applet + public Api_2_Tkr_Atim_2() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Atim_2 thisApplet = new Api_2_Tkr_Atim_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, + (short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + /** + * Method called by the processToolkit() method to know if short + * has alread been added to an array + */ + private boolean isInArray(short temp, short[] Array) { + boolean isInArray = false; + + for(short i = ((short) (Array.length-1)); ((i > (short) -1) && (!isInArray));i--) { + isInArray = (Array[i] == temp); + } + return isInArray; + } + + /** + * Method called by the processToolkit() method to know if an ID + * belongs to the timer ID interval + */ + private boolean isTimerID(short ID) { + boolean isTimerID; + + isTimerID = (ID>(short)(MIN_TIMER_ID-1)) && (ID<(short)(MAX_TIMER_ID+1)); + return isTimerID; + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + short temp = 0; + short i; + // ----------------------------------------------------------------- + // Test Case 4: 4 * allocateTimer() + // No exception shall be thrown. + // Timer ID returned shall be between + // 0x01 and 0x08 inclusive. + // It shall be different after each call. + // ----------------------------------------------------------------- + testCaseNb = (byte) 1; + bRes = true; + + try { + for (i=(short)0; (i<(short)4) && (bRes); i++) { + temp = obReg.allocateTimer(); + bRes = (isTimerID(temp)) && (!this.isInArray(temp,Timers)); + Timers[i] = temp; + } + } + catch (Exception e) { + bRes = false; + } + + for (i=(short)0; (i<(short)4) && (bRes); i++) { + if (isTimerID(Timers[i])) { + try { + obReg.releaseTimer((byte) Timers[i]); + } + catch (Exception e) { + } + } + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_3.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_3.java new file mode 100644 index 0000000000000000000000000000000000000000..9249d6dc47119be5011a80bfadccacbe169568f0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Api_2_Tkr_Atim_3.java @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_atim; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import uicc.system.*; +import javacard.framework.*; +import uicc.test.util.*; + + +/** + * uicc.toolkit package, ToolkitRegistry interface, allocateTimer() method + * applet 3 + */ +public class Api_2_Tkr_Atim_3 extends TestToolkitApplet { + + private byte testCaseNb; + private static boolean bRes; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'3'}; + + // Constructor of the applet + public Api_2_Tkr_Atim_3() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // create a new applet instance + Api_2_Tkr_Atim_3 thisApplet = new Api_2_Tkr_Atim_3(); + + // register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), bArray[bOffset]); + + // initialise the data of the test applet + thisApplet.init(); + + // registration to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, + (short) MenuInit.length, (byte) 0, false, + (byte) 0, (short) 0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + // ----------------------------------------------------------------- + // Test Case 5: The applet allocates 1 timer + // Shall throw a ToolkitException + // with reason NO_TIMER_AVAILABLE + // ----------------------------------------------------------------- + testCaseNb = (byte)0x01; + bRes = false; + + try { + obReg.allocateTimer(); + } + catch (ToolkitException e) { + bRes = e.getReason() == ToolkitException.NO_TIMER_AVAILABLE; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } +} \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Test_Api_2_Tkr_Atim.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Test_Api_2_Tkr_Atim.java new file mode 100644 index 0000000000000000000000000000000000000000..9eb4f32d411bf893937670f7bf7a1cea9f1f5863 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/Test_Api_2_Tkr_Atim.java @@ -0,0 +1,140 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * allocateTimer() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_atim; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Atim extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_atim"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 20020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 20020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 20030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 20030102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Atim() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("0101"); + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "04" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0102" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.reset(); + test.terminalProfileSession("0101"); + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0103" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010020"); + + // test case 1 to 3: trigger applet1 + response = test.envelopeMenuSelection("100101",""); + result = response.checkSw("9000"); + + // all timers expire + response = test.envelopeTimerExpiration("240108"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240107"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240106"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240105"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240104"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240103"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240102"); + result &= response.checkSw("9000"); + response = test.envelopeTimerExpiration("240101"); + result &= response.checkSw("9000"); + + // test case 4: trigger applet2 + response = test.envelopeMenuSelection("100102",""); + result &= response.checkSw("9000"); + + // test case 5: trigger applet3 + response = test.envelopeMenuSelection("100103",""); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "03CCCCCC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01CC"); + + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..13122a030da8cf0ffb95724dffcc6e746d80187c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/applet.opt @@ -0,0 +1,6 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x02:0x00:0x01 uicc.test.toolkit.api_2_tkr_atim.Api_2_Tkr_Atim_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x03:0x00:0x01 uicc.test.toolkit.api_2_tkr_atim.Api_2_Tkr_Atim_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_atim.Api_2_Tkr_Atim_1 +uicc.test.toolkit.api_2_tkr_atim +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/javacard/api_2_tkr_atim.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/javacard/api_2_tkr_atim.cap new file mode 100644 index 0000000000000000000000000000000000000000..c82f595a9661875961ef63090ce4514793f3cb64 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_atim/javacard/api_2_tkr_atim.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/Api_2_Tkr_Cevt_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/Api_2_Tkr_Cevt_1.java new file mode 100644 index 0000000000000000000000000000000000000000..bc5fe192b8edd9f93fd99a1ea52cf71dfc65edfd --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/Api_2_Tkr_Cevt_1.java @@ -0,0 +1,231 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_cevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.access.*; +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, clearEvent() method + * applet 1 + */ +public class Api_2_Tkr_Cevt_1 extends TestToolkitApplet { + + // Not allowed events for the ClearEvent() method + private static short[] NOT_ALLOWED_CLEAR_EVENTS = { EVENT_MENU_SELECTION, EVENT_MENU_SELECTION_HELP_REQUEST, + EVENT_TIMER_EXPIRATION, EVENT_STATUS_COMMAND, + EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION}; + + // Not supported events for the setEvent() method + private static short NOT_SUPPORTED_SETEVENT_10 = 10; + private static short NOT_SUPPORTED_SETEVENT_24 = 24; + + // Event value range + private static short MIN_EVENT_NB = 7; + private static short MAX_EVENT_NB = 29; + + // Events allowed and supported for clearEvent() method + private static short MAX_EVENT = 22; // 27 events - 5 not allowed events + private short[] EventList = new short[MAX_EVENT]; + + // Indicate if that applet has already been triggered once + // -->all events have been cleared + private boolean eventsCleared = false; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Cevt_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Cevt_1 thisApplet = new Api_2_Tkr_Cevt_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the processToolkit() method to know if event + * is an allowed event for the clearEvent() method + */ + private boolean isEventAllowed(short event) { + boolean allowed = true; + + for(short i = 0; (i < NOT_ALLOWED_CLEAR_EVENTS.length) && (allowed); i++) { + allowed = (NOT_ALLOWED_CLEAR_EVENTS[i] != event); + } + return allowed; + } + + /** + * Method called by the processToolkit() method to know if event + * is a supported event for the setEvent() method + */ + private boolean isEventSupported(short event) { + return (((event != NOT_SUPPORTED_SETEVENT_10) + &&(event != NOT_SUPPORTED_SETEVENT_24) + && (event >= MIN_EVENT_NB) + && (event <= MAX_EVENT_NB)) + || (event == EVENT_UNRECOGNIZED_ENVELOPE) + || (event == EVENT_PROFILE_DOWNLOAD) + || (event == EVENT_PROACTIVE_HANDLER_AVAILABLE) + || (event == EVENT_EXTERNAL_FILE_UPDATE) + || (event == EVENT_APPLICATION_DESELECT) + || (event == EVENT_FIRST_COMMAND_AFTER_ATR)); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes ; + byte testCaseNb ; + short j = 0; + + // Build the allowed and supported events list to be set AND clear + for(short i = MIN_EVENT_NB; i <= MAX_EVENT_NB;i++) { + + if ((this.isEventAllowed(i)) && (this.isEventSupported(i))) { + EventList[j] = i; + j++; + } + } + EventList[j++] = EVENT_UNRECOGNIZED_ENVELOPE; + EventList[j++] = EVENT_PROFILE_DOWNLOAD; + EventList[j++] = EVENT_PROACTIVE_HANDLER_AVAILABLE; + EventList[j++] = EVENT_APPLICATION_DESELECT; + EventList[j++] = EVENT_FIRST_COMMAND_AFTER_ATR; + EventList[j] = EVENT_EXTERNAL_FILE_UPDATE; + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + // ----------------------------------------------------------------- + // Test Case 1 : Clear ALLOWED unregistered events + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + + bRes = false; + + for(short i=0; i < (short)(EventList.length); i++) { + bRes = false; + + if ((this.isEventAllowed(EventList[i])) && (this.isEventSupported(i))) { + try { + obReg.clearEvent(EventList[i]); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + if (obReg.isEventSet(EventList[i])) { + // A cleared event should not be set anymore + bRes = false; + break; + } + } + } + reportTestOutcome(testCaseNb,bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : Clear registered events + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + // set all allowed and supported events + + try { + // Do not perform setEvent() with EVENT_EXTERNAL_FILE_UPDATE + for(short i=0; i < (short)(EventList.length - 1 ); i++) { + + if ((this.isEventAllowed(EventList[i])) && (this.isEventSupported(EventList[i]))) { + obReg.setEvent(EventList[i]); + } + } + // Register to EVENT_EXTERNAL_FILE_UPDATE + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, UICCSystem.getTheUICCView(JCSystem.NOT_A_TRANSIENT_OBJECT)); + bRes = true; + } + catch (Exception e) { // No exception should be thrown + bRes = false ; + } + + // clear all set events + if (bRes) { + try { + for(short i=0; i < (short)(MAX_EVENT); i++) { + + if (this.isEventAllowed(EventList[i])) { + obReg.clearEvent(EventList[i]); + + // check events are not set anymore + if(obReg.isEventSet(EventList[i])) { + bRes = false; + break; + } + } + } + } + catch (Exception e) { + bRes = false ; + } + } + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3 : Clear NOT ALLOWED events + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = true; + + for (short i = 0; (i < NOT_ALLOWED_CLEAR_EVENTS.length) && (bRes); i++) { + bRes = false; + try { + obReg.clearEvent(NOT_ALLOWED_CLEAR_EVENTS[i]); + } + catch (ToolkitException e) { // Only EVENT_NOT_ALLOWED should be thrown + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + } + reportTestOutcome(testCaseNb, bRes); + + // -------------------------------------------------------------------- + // Test Case 4 : Check applet is not triggered by an + // envelope(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) command + // -------------------------------------------------------------------- + testCaseNb = (byte)4; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + testCaseNb = (byte)4; + reportTestOutcome(testCaseNb, false); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/Test_Api_2_Tkr_Cevt.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/Test_Api_2_Tkr_Cevt.java new file mode 100644 index 0000000000000000000000000000000000000000..b647eea8e32f8a514a866116f7b3d46af3446207 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/Test_Api_2_Tkr_Cevt.java @@ -0,0 +1,81 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * clearEvent() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_cevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Cevt extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_cevt"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Cevt() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8104" + // TLV UICC Access application specific parameters + "00" + // LV UICC File System AID field + "0100" + // LV Access Domain for UICC file system = ALWAYS + "00" ); // LV Access Domain DAP field + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // test case 1 to 3: trigger applet1 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // test case 4: trigger applet1 + response = test.envelopeEventDownloadUserActivity(); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04CCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..90cd5552779b2796584578cb6d639f6c40024895 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_cevt.Api_2_Tkr_Cevt_1 +uicc.test.toolkit.api_2_tkr_cevt +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/javacard/api_2_tkr_cevt.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/javacard/api_2_tkr_cevt.cap new file mode 100644 index 0000000000000000000000000000000000000000..1d9584eeb8371376897f83563d83a23f908453e8 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cevt/javacard/api_2_tkr_cevt.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/Api_2_Tkr_Cmet_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/Api_2_Tkr_Cmet_1.java new file mode 100644 index 0000000000000000000000000000000000000000..1f1f8d9fc3862106747bb5f2215ca0087baa1744 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/Api_2_Tkr_Cmet_1.java @@ -0,0 +1,742 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_cmet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + + +/** + * uicc.toolkit package, Toolkit Registry, changeMenuEntry() test + * applet 1 + */ +public class Api_2_Tkr_Cmet_1 extends TestToolkitApplet { + + private static byte[] MenuInit = {(byte)'I', (byte)'n', (byte)'i', (byte)'t', (byte)'1'}; + + private static byte[] Init = {(byte)'I', (byte)'n', (byte)'i', (byte)'t'}; + + private static byte[] MenuAllBuffer = {(byte)'U', (byte)'s', (byte)'e', (byte)'A', (byte)'l', + (byte)'l', (byte)'B', (byte)'u', (byte)'f', (byte)'f', + (byte)'e', (byte)'r' }; + + private static byte[] MenuPartBuffer = {(byte)'U', (byte)'s', (byte)'e', (byte)'P', (byte)'a', + (byte)'r', (byte)'t', (byte)'O', (byte)'f', (byte)'B', + (byte)'u', (byte)'f', (byte)'f', (byte)'e', (byte)'r'}; + + private static byte[] LengthEquals0 = {(byte)'L', (byte)'e', (byte)'n', (byte)'g', (byte)'t', + (byte)'h', (byte)'E', (byte)'q', (byte)'u', (byte)'a', + (byte)'l', (byte)'s', (byte)'0'}; + + private static byte[] NextActionIndic = {(byte)'N', (byte)'e', (byte)'x', (byte)'t', (byte)'A', + (byte)'c', (byte)'t', (byte)'i', (byte)'o', (byte)'n', + (byte)'I', (byte)'n', (byte)'d', (byte)'i', (byte)'c'}; + + private static byte[] HelpSupported = {(byte)'H', (byte)'e', (byte)'l', (byte)'p', (byte)'S', + (byte)'u', (byte)'p', (byte)'p', (byte)'o', (byte)'r', + (byte)'t', (byte)'e', (byte)'d'}; + + private static byte[] IconQualifier = {(byte)'I', (byte)'c', (byte)'o', (byte)'n', (byte)'Q', + (byte)'u', (byte)'a', (byte)'l', (byte)'i', (byte)'f', + (byte)'i', (byte)'e', (byte)'r'}; + + private static byte[] EnableEntry = {(byte)'E', (byte)'n', (byte)'a', (byte)'b', (byte)'l', + (byte)'e', (byte)'E', (byte)'n', (byte)'t', (byte)'r', + (byte)'y'}; + + private static byte[] Violation = {(byte)'V', (byte)'i', (byte)'o', (byte)'l', (byte)'a', + (byte)'t', (byte)'i',(byte)'o', (byte)'n'}; + + private static byte[] WarningViolation = {(byte)'W', (byte)'a', (byte)'r', (byte)'n', (byte)'i', + (byte)'n', (byte)'g', (byte)'V', (byte)'i', (byte)'o', + (byte)'l', (byte)'a', (byte)'t', (byte)'i', (byte)'o', + (byte)'n'}; + + private byte resultat = (byte)0; + + private short CallNB = 0; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Cmet_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Cmet_1 thisApplet = new Api_2_Tkr_Cmet_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE and EVENT_MENU_SELECTION + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + thisApplet.resultat = thisApplet.obReg.initMenuEntry(MenuInit, (short)0, (short)5, (byte)0, false, + (byte)0, (short)0); + MenuInit [4] = (byte)'2'; + thisApplet.resultat = thisApplet.obReg.initMenuEntry(MenuInit, (short)0, (short)5, (byte)0, false, + (byte)0, (short)0); + + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + + // Result of tests + boolean bRes ; + + // Number of tests + byte testCaseNb = (byte)0x14; + + byte TLV; + byte ItemID; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + CallNB++; + if ( CallNB < 11) testCaseNb = (byte)CallNB; + bRes = false; + + switch (CallNB) { + + case 1 : + // ----------------------------------------------------------------- + // Test Case 1 : Applet changes the entry's title by menuEntry buffer + // 1- changeMenuEntry()with parameters: + // Id = 02 + // MenuEntry = "UseAllBuffer" + // Offset = 0 + // Length = menuEntry.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + try { + obReg.changeMenuEntry((byte)2, MenuAllBuffer, (short)0, (short)MenuAllBuffer.length, + (byte)0, false, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + break; + + case 2 : + // ----------------------------------------------------------------- + // Test Case 2 : Changing the title with part of menuEntry buffer + // 1- changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "UsePartOfBuffer" + // Offset = 3 + // Length = menuEntry.length - 3 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + try { + obReg.changeMenuEntry((byte)1, MenuPartBuffer, (short)3, (short)(MenuPartBuffer.length - 3), + (byte)0, false, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + break; + + case 3 : + // ----------------------------------------------------------------- + // Test Case 3 : Length = 0 + // 1- changeMenuEntry()with parameters: + // Id = 01/02 + // MenuEntry = "LengthEquals0" + // Offset = 0 + // Length = 0 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + try { + obReg.changeMenuEntry((byte)1, LengthEquals0, (short)0, (short)0, + (byte)0, false, (byte)0, (short)0); + + obReg.changeMenuEntry((byte)2, LengthEquals0, (short)0, (short)0, + (byte)0, false, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + break; + + case 4 : + // ----------------------------------------------------------------- + // Test Case 4 : Setting a next action indicator != 0 + // 1- changeMenuEntry()with parameters: + // Id = 02 + // MenuEntry = "NextActionIndic" + // Offset = 0 + // Length = menuEntry.length + // NextAction = 10 (SETUP CALL) + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // 4- changeMenuEntry()with parameters: + // Id = 02 + // MenuEntry = "NextActionIndic" + // Offset = 0 + // Length = menuEntry.length + // NextAction = 10 (SETUP CALL) + // HelpSupported = true + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + obReg.changeMenuEntry((byte)2, NextActionIndic, (short)0, (short)NextActionIndic.length, + (byte)16, false, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + try { + obReg.changeMenuEntry((byte)2, NextActionIndic, (short)0, (short)NextActionIndic.length, + (byte)16, true, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + break; + + case 6 : + + // ----------------------------------------------------------------- + // Test Case 6 : help supported=true + // 1- changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "HelpSupported" + // Offset = 0 + // Length = menuEntry.length + // NextAction = 0 + // HelpSupported = true + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + try { + obReg.changeMenuEntry((byte)1, HelpSupported, (short)0, (short)HelpSupported.length, + (byte)0, true, (byte)0, (short)0); + + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + break; + + case 8 : + // ----------------------------------------------------------------- + // Test Case 8 : Setting icons + // 1- changeMenuEntry()with parameters: + // Id = 01/02 + // MenuEntry = "IconQualifier" + // Offset = 0 + // Length = menuEntry.length + // NextAction = 10 (SETUP CALL) + // HelpSupported = false + // IconQualifier = 01 + // IconIdentifier = 01/02 + // No exception shall be thrown + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + try { + obReg.changeMenuEntry((byte)1, IconQualifier, (short)0, (short)IconQualifier.length, + (byte)0, false, (byte)1, (short)1); + + obReg.changeMenuEntry((byte)2, IconQualifier, (short)0, (short)IconQualifier.length, + (byte)0, false, (byte)1, (short)2); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + break; + + case 9 : + // ----------------------------------------------------------------- + // Test Case 9 : MenuEntry is disabled + // 1- disableEntry(01) + // No exception shall be thrown + // 2- changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "EnableEntry" + // Offset = 0 + // Length = menuEntry.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // No exception shall be thrown + // 3- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 4- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + try { + obReg.disableMenuEntry((byte)1); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, EnableEntry, (short)0, (short)EnableEntry.length, + (byte)0, false, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes) ; + + break; + + case 10 : + // ----------------------------------------------------------------- + // Test Case 10 : MenuEntry is null + // Shall throw java.lang.NullPointerException + // ----------------------------------------------------------------- + testCaseNb = (byte)10; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, null, (short)0, (short)1, + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.NullPointerException e) { + bRes = true; + } + catch (Exception e){ + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 11: Offset causes access outside array bounds + // changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "Violation" + // Offset = menuEntry.length + // Length = 1 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // java.lang.ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)11; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, Violation, (short)Violation.length, (short)1, + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e){ + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 12: Big Offset causes access outside array bounds + // changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "Violation" + // Offset = 255 + // Length = 1 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // java.lang.ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)12; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, Violation, (short)255, (short)1, + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e){ + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 13: Offset < 0 causes access outside array bounds + // changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "Violation" + // Offset = -1 + // Length = 1 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // java.lang.ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)13; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, Violation, (short)-1, (short)1, + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e){ + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 14: Length causes access outside array bounds + // changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "Violation" + // Offset = 0 + // Length = MenuEntry.length + 1 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // java.lang.ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)14; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, Violation, (short)0, (short)(Violation.length + 1), + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e){ + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 15: Length < 0 causes access outside array bounds + // changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "Violation" + // Offset = 0 + // Length = -1 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // java.lang.ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)15; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, Violation, (short)0, (short)-1, + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 16: Both offset and length causes access + // outside array bounds + // changeMenuEntry()with parameters: + // Id = 01 + // MenuEntry = "Violation" + // Offset = 4 + // Length = MenuEntry.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // java.lang.ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)16; + bRes = false; + + try { + obReg.changeMenuEntry((byte)1, Violation, (short)4, (short)Violation.length, + (byte)0, false, (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 17: Invalid ID used + // changeMenuEntry()with parameters: + // Id = 00 + // MenuEntry = "Violation" + // Offset = 0 + // Length = MenuEntry.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // MENU_ENTRY_NOT_FOUND ToolKit Exception + // ----------------------------------------------------------------- + testCaseNb = (byte)17; + bRes = false; + + try { + obReg.changeMenuEntry((byte)0, Violation, (short)0, (short)Violation.length, + (byte)0, false, (byte)0, (short)0); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 18: ID isn't allocated to a menu entry + // of this applet instance + // changeMenuEntry()with parameters: + // Id = 0A + // MenuEntry = "Violation" + // Offset = 0 + // Length = MenuEntry.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // MENU_ENTRY_NOT_FOUND ToolKit Exception + // ----------------------------------------------------------------- + testCaseNb = (byte)18; + bRes = false; + + try { + obReg.changeMenuEntry((byte)10, Violation, (short)0, (short)Violation.length, + (byte)0, false, (byte)0, (short)0); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 19: The text is bigger than the allocated space + // changeMenuEntry()with parameters: + // Id = 02 + // MenuEntry = "WarningViolation" + // Offset = 0 + // Length = MenuEntry.length + 10 + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // ALLOWED_LENGTH_EXCEEDED ToolKit Exception + // ----------------------------------------------------------------- + testCaseNb = (byte)19; + bRes = false; + + try { + obReg.changeMenuEntry((byte)2, WarningViolation, (short)0, (short)(WarningViolation.length ), + (byte)0, false, (byte)0, (short)0); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.ALLOWED_LENGTH_EXCEEDED); + } + catch (Exception e) { + bRes = false; + } + + case 11 : + + reportTestOutcome(testCaseNb, bRes) ; + + // ----------------------------------------------------------------- + // Test Case 20: Applet changes the entry's title by menuEntry + // buffer, with a smaller length + // than the initial length + // 1- Id = 02 + // MenuEntry = "Init" + // Offset = 0 + // Length = MenuEntry.length + // NextAction = 0 + // HelpSupported = false + // IconQualifier = 0 + // IconIdentifier = 0 + // Shall throw a + // 2- isEventSet(EVENT_MENU_SELECTION) + // shall return true + // 3- isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // shall return false + // ----------------------------------------------------------------- + testCaseNb = (byte)20; + bRes = false; + + try { + obReg.changeMenuEntry((byte)2, Init, (short)0, (short)(Init.length), + (byte)0, false, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + break; + } + + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + break; + } + + reportTestOutcome(testCaseNb, bRes); + if ((CallNB == 4) || (CallNB == 6)) { + CallNB++; + } + } + else { + // ----------------------------------------------------------------- + // Test Case 5 : Checking applet isn't triggered by a + // MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + // ----------------------------------------------------------------- + // Test Case 7 : Checking applet is triggered by a + // MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + if (event == EVENT_MENU_SELECTION_HELP_REQUEST) { + if (CallNB == 5){ + if (envHdlr.getItemIdentifier() == (byte)0x02) + reportTestOutcome((byte)CallNB, true); + } + if (CallNB == 7){ + if (envHdlr.getItemIdentifier() == (byte)0x01) { + reportTestOutcome((byte)CallNB, true); + } + } + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/Test_Api_2_Tkr_Cmet.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/Test_Api_2_Tkr_Cmet.java new file mode 100644 index 0000000000000000000000000000000000000000..54308f28176b9e746a41c188c0ba23e23e02a017 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/Test_Api_2_Tkr_Cmet.java @@ -0,0 +1,164 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * changeMenuEntry() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_cmet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Cmet extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_cmet"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Cmet() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applet + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010020"); + + // test case 1 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("912D"); + response = test.fetch("2D"); + result &= response.checkData("D02B8103 01250082 02818285 09554943" + + "43205445 53548F06 01496E69 74318F0D" + + "02557365 416C6C42 75666665 72"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 2 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9134"); + response = test.fetch("34"); + result &= response.checkData("D0328103 01250082 02818285 09554943" + + "43205445 53548F0D 01506172 744F6642" + + "75666665 728F0D02 55736541 6C6C4275" + + "66666572"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 3 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911C"); + response = test.fetch("1C"); + result &= response.checkData("D01A8103 01250082 02818285 09554943" + + "43205445 53548F01 018F0102"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 4 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("912F"); + response = test.fetch("2F"); + result &= response.checkData("D02D8103 01258082 02818285 09554943" + + "43205445 53548F01 018F1002 4E657874" + + "41637469 6F6E496E 64696318 020010"); + response = test.terminalResponse("81030125 80820282 81830100"); + result &= response.checkSw("9000"); + + // test case 5 + response = test.envelopeMenuSelection("900102", "9500"); + result &= response.checkSw("9000"); + + // test case 6 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("913C"); + response = test.fetch("3C"); + result &= response.checkData("D03A8103 01258082 02818285 09554943" + + "43205445 53548F0E 0148656C 70537570" + + "706F7274 65648F10 024E6578 74416374" + + "696F6E49 6E646963 18020010"); + response = test.terminalResponse("81030125 80820282 81830100"); + result &= response.checkSw("9000"); + + // test case 7 + response = test.envelopeMenuSelection("900101", "9500"); + result &= response.checkSw("9000"); + + // test case 8 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("913B"); + response = test.fetch("3B"); + result &= response.checkData("D0398103 01250082 02818285 09554943" + + "43205445 53548F0E 0149636F 6E517561" + + "6C696669 65728F0E 0249636F 6E517561" + + "6C696669 65721F03 010102"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 9 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9134"); + response = test.fetch("34"); + result &= response.checkData("D0328103 01250082 02818285 09554943" + + "43205445 53548F0C 01456E61 626C6545" + + "6E747279 8F0E0249 636F6E51 75616C69" + + "66696572"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + + // test case 10..19 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("912B"); + + // test case 20 + response = test.fetch("2B"); + result &= response.checkData("D0298103 01250082 02818285 09554943" + + "43205445 53548F0C 01456E61 626C6545" + + "6E747279 8F050249 6E6974"); + response = test.terminalResponse("81030125 00820282 81830100"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "14CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..aea9352100b38803637f24b3959236fb76d277bf --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_cmet.Api_2_Tkr_Cmet_1 +uicc.test.toolkit.api_2_tkr_cmet +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/javacard/api_2_tkr_cmet.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/javacard/api_2_tkr_cmet.cap new file mode 100644 index 0000000000000000000000000000000000000000..bb187e604e795087cfa0cee8e2e63af6fcaddeaf Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_cmet/javacard/api_2_tkr_cmet.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/Api_2_Tkr_Dmet_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/Api_2_Tkr_Dmet_1.java new file mode 100644 index 0000000000000000000000000000000000000000..b5842773468c021dcb42be2b7607c096468e90e7 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/Api_2_Tkr_Dmet_1.java @@ -0,0 +1,187 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_dmet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, disableMenuEntry() method + * applet 1 + */ +public class Api_2_Tkr_Dmet_1 extends TestToolkitApplet { + + private static byte[] MenuInit = {(byte)'I', (byte)'n', (byte)'i', (byte)'t'}; + private static final boolean HELP_REQUESTED = true; + private static final boolean HELP_NOT_REQUESTED = false; + + boolean bRes = false; + byte testCaseNb; + + private byte callNb = (byte) 0; + private byte resultat = (byte) 0; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Dmet_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Dmet_1 thisApplet = new Api_2_Tkr_Dmet_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE and EVENT_MENU_SELECTION + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + thisApplet.obReg.initMenuEntry(MenuInit, (short)0, (short)4, (byte)0, + HELP_NOT_REQUESTED, (byte)0, (short)0); + //MenuInit [3] = (byte)'2'; + thisApplet.obReg.initMenuEntry(MenuInit, (short)0, (short)4, (byte)0, + HELP_NOT_REQUESTED, (byte)0, (short)0); + + } + + /** + * method called by the CAT RE at the installation of the applet + */ + public void processToolkit(short event) { + + // Increasing the number of triggerings + ++callNb; + + switch(callNb) { + case (byte)1 : + + short i; + // ----------------------------------------------------------------- + // Test Case 1 : Check the menu state before disabling a previously + // enabled entry not registered to EVENT_MENU_SELECTION_HELP_REQUEST. + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + + bRes = obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte)2 : + // ----------------------------------------------------------------- + // Test case 2 : Check the menu state after disabling a previously + // enabled entry not registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + try { + obReg.disableMenuEntry((byte)0x01); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && + obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)3: + + // ----------------------------------------------------------------- + // Test Case 3 : Check the menu before disabling a previously enabled + // entry registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = false; + + try { + obReg.changeMenuEntry((byte)0x02, MenuInit, (short)0, (short)4, + (byte)0, HELP_REQUESTED, (byte)0, (short)0); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && + obReg.isEventSet(EVENT_MENU_SELECTION) && + obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte)4 : + // ----------------------------------------------------------------- + // Test case 4 : Check the menu after disabling a previously enabled + // entry registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + testCaseNb = (byte)4; + bRes = false; + + try { + obReg.disableMenuEntry((byte)02); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && + obReg.isEventSet(EVENT_MENU_SELECTION) && + obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes) ; + break; + + case (byte) 5 : + // ----------------------------------------------------------------- + // Test Case 5 : Disabling invalid entries + // ----------------------------------------------------------------- + testCaseNb = (byte)5; + bRes = false; + + try { + obReg.disableMenuEntry((byte)0); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { bRes = false; } + + if (bRes) { + for (i = 3; (i<256) && bRes;i++){ + bRes = false; + try{ + obReg.disableMenuEntry((byte)i); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + } + } + reportTestOutcome(testCaseNb, bRes) ; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/Test_Api_2_Tkr_Dmet.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/Test_Api_2_Tkr_Dmet.java new file mode 100644 index 0000000000000000000000000000000000000000..5b30c0b19ba3179b1c517534c4031ee6320d4431 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/Test_Api_2_Tkr_Dmet.java @@ -0,0 +1,112 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * disableMenuEntry() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_dmet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Dmet extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_dmet"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Dmet() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + response = test.terminalProfile("09010020"); + result = response.checkSw("9124"); + response = test.fetch("24"); + result &= response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F05 01496E69 748F0502" + + "496E6974"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 1 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + // test case 2 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911D"); + response = test.fetch("1D"); + result &= response.checkData("D01B8103 01250082 02818285 09554943" + + "43205445 53548F05 02496E69 74"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 3 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911D"); + response = test.fetch("1D"); + result &= response.checkData("D01B8103 01258082 02818285 09554943" + + "43205445 53548F05 02496E69 74"); + response = test.terminalResponse("81030125 80820282 81830100"); + result &= response.checkSw("9000"); + + // test case 4 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9118"); + response = test.fetch("18"); + result &= response.checkData("D0168103 01250082 02818285 09554943" + + "43205445 53548F00"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 5 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..52b32dc49c3708892e1cf90503724943c172bfa4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_dmet.Api_2_Tkr_Dmet_1 +uicc.test.toolkit.api_2_tkr_dmet +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/javacard/api_2_tkr_dmet.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/javacard/api_2_tkr_dmet.cap new file mode 100644 index 0000000000000000000000000000000000000000..accd7cc73e86f87c786b1a0749dae5d844c68450 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_dmet/javacard/api_2_tkr_dmet.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/Api_2_Tkr_Drfes_Bss_Bsb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/Api_2_Tkr_Drfes_Bss_Bsb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..cd430f5f952904241386d8132c57913c6500636e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/Api_2_Tkr_Drfes_Bss_Bsb_1.java @@ -0,0 +1,743 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_drfes_bss_bsb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, deregisterFileEvent() method + * applet 1 + */ +public class Api_2_Tkr_Drfes_Bss_Bsb_1 extends TestToolkitApplet { + + private boolean bRes = true; + private byte callNb = 1; + private boolean hasBeenTriggered = false; + + private byte[] adf1Aid; + private byte[] baADFAid15; + private byte[] baADFAid18; + + private byte[] baFileList; + private short sFileListLength; + + private byte[] baFileList1a = { + (byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x0C + }; + + private byte[] baFileList1b = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09 + }; + + private byte[] baFileList1c = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x0C + }; + + private byte[] baFileList2a = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList2b = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList3a = baFileList2b; + + private byte[] baFileList3b = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03 + }; + + private byte[] baFileList4a = { + (byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x0C + }; + + private byte[] baFileList4b = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09 + }; + + private byte[] baFileList4c = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x0C + }; + + private byte[] baFileList5a = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList5b = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList6a = baFileList5b; + + private byte[] baFileList6b = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03 + }; + + + static final byte FILE_LIST_TAG = (byte) 0x92; + + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Drfes_Bss_Bsb_1() { + baFileList = new byte[10]; + adf1Aid = new byte[16]; + baADFAid15 = new byte[15]; + baADFAid18 = new byte[18]; + UICCTestConstants uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1,(short)0,adf1Aid,(short)0,(short)adf1Aid.length); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Drfes_Bss_Bsb_1 thisApplet = new Api_2_Tkr_Drfes_Bss_Bsb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialize the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register to EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + switch (callNb++) { + + /** Testcase 1 ***************************************** + * Deregister EF under MF + *******************************************************/ + + case 1: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 2: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1b, (short) 0, (short) baFileList1b.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 3: + try { + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1c, (short) 0, (short) baFileList1c.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 4: + try { + bRes &= !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 1, bRes); + break; + + + /** Testcase 2 ***************************************** + * Deregister DF under MF + *******************************************************/ + + case 5: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList2a, (short) 0, (short) baFileList2a.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 6: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList2b, (short) 0, (short) baFileList2b.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 2, bRes); + break; + + + /** Testcase 3 ***************************************** + * Deregister EF does not affect parent DF + *******************************************************/ + + case 7: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList3a, (short) 0, (short) baFileList3a.length, + null, (short) 0, (byte) 0 ); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 8: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList3b, (short) 0, (short) baFileList3b.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 3, bRes); + break; + + + /** Testcase 4 ***************************************** + * Deregister EF under ADF1 + *******************************************************/ + + case 9: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList3a, (short) 0, (short) baFileList3a.length, + null, (short) 0, (byte) 0 ); + + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList4a, (short) 0, (short) baFileList4a.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 10: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList4b, (short) 0, (short) baFileList4b.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 11: + try { + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList4c, (short) 0, (short) baFileList4c.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 12: + try { + bRes &= !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 4, bRes); + break; + + + /** Testcase 5 ***************************************** + * Deregister DF does not affect child EF (under ADF1) + *******************************************************/ + + case 13: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList5a, (short) 0, (short) baFileList5a.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 14: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList5b, (short) 0, (short) baFileList5b.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 5, bRes); + break; + + /** Testcase 6 ***************************************** + * Deregister EF does not affect parent DF (under ADF1) + *******************************************************/ + + case 15: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6a, (short) 0, (short) baFileList6a.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 16: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6b, (short) 0, (short) baFileList6b.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 6, bRes); + break; + + + /** Testcase 7 ***************************************** + * NullPointerException Exception + *******************************************************/ + + case 17: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + null, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 7, bRes); + break; + + + /** Testcase 8 ***************************************** + * sOffset1 >= baFileList.length + *******************************************************/ + + case 18: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1c, (short) 8, (short) 4, + null, (short) 0, (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 8, bRes); + break; + + /** Testcase 9 ***************************************** + * sOffset1 < 0 + *******************************************************/ + + case 19: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) -1, (short) 4, + null, (short) 0, (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 9, bRes); + break; + + /** Testcase 10 **************************************** + * sLength1 > baFileList.length + *******************************************************/ + + case 20: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1c, (short) 0, (short) 10, + null, (short) 0, (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 10, bRes); + break; + + + /** Testcase 11 **************************************** + * sOffset1 + sLength1 > baFileList.length + *******************************************************/ + + case 21: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1c, (short) 5, (short) 4, + null, (short) 0, (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 11, bRes); + break; + + + /** Testcase 12 **************************************** + * sLength1 < 0 + *******************************************************/ + + case 22: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) -1, + null, (short) 0, (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 12, bRes); + break; + + + /** Testcase 13 ***************************************** + * sOffset2 >= baFileList.length + *******************************************************/ + + case 23: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + baADFAid15, (short) 15, (byte) 6 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 13, bRes); + break; + + + /** Testcase 14 ***************************************** + * sOffset2 < 0 + *******************************************************/ + + case 24: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + baADFAid15, (short) -1, (byte) 6 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 14, bRes); + break; + + + /** Testcase 15 ***************************************** + * sLength2 > baFileList.length + *******************************************************/ + + case 25: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + baADFAid15, (short) 0, (byte) 16 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 15, bRes); + break; + + + /** Testcase 16 ***************************************** + * sOffset2 + sLength2 > baFileList.length + *******************************************************/ + + case 26: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + baADFAid15, (short) 10, (byte) 6 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 16, bRes); + break; + + + /** Testcase 17 ***************************************** + * ILLEGAL_VALUE Exception + *******************************************************/ + + case 27: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + baADFAid18, (short) 0, (byte) 4 ); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_VALUE); + } + catch (Exception e) { + bRes = false; + } + + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1a, (short) 0, (short) baFileList1a.length, + baADFAid18, (short) 0, (byte) 18 ); + } + catch (SystemException e) { + bRes &= (e.getReason() == SystemException.ILLEGAL_VALUE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome((byte) 17, bRes); + break; + + + /** Testcase 18 ***************************************** + * EVENT_MENU_SELECTION not allowed + *******************************************************/ + + case 28: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_MENU_SELECTION, + baFileList1a, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 18, bRes); + break; + + + /** Testcase 19 ***************************************** + * EVENT_MENU_SELECTION_HELP_REQUEST not allowed + *******************************************************/ + + case 29: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_MENU_SELECTION_HELP_REQUEST, + baFileList1a, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 19, bRes); + break; + + + /** Testcase 20 ***************************************** + * EVENT_TIMER_EXPIRATION not allowed + *******************************************************/ + + case 30: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_TIMER_EXPIRATION, + baFileList1a, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 20, bRes); + break; + + + /** Testcase 21 ***************************************** + * EVENT_STATUS_COMMAND not allowed + *******************************************************/ + + case 31: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_STATUS_COMMAND, + baFileList1a, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 21, bRes); + break; + + + /** Testcase 22 ***************************************** + * EVENT_NOT_SUPPORTED Exception + *******************************************************/ + + case 32: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_PROFILE_DOWNLOAD, + baFileList1a, (short) 0, (short) baFileList1a.length, + null, (short) 0, (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_SUPPORTED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 22, bRes); + break; + + } + } + + else if (event == EVENT_EXTERNAL_FILE_UPDATE) { + // If triggered on EVENT_EXTERNAL_FILE_UPDATE the applet stores the triggering File List in baFileList + sFileListLength = EnvelopeHandlerSystem.getTheHandler().findAndCopyValue(FILE_LIST_TAG, baFileList, (short)0); + hasBeenTriggered = true; + } + + else if (event == EVENT_CALL_CONTROL_BY_NAA) { + // If triggered on EVENT_CALL_CONTROL_BY_NAA the applet returns the latest triggering File List + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (hasBeenTriggered) { + envRespHdlr.appendArray(baFileList, (short) 0, (short) sFileListLength); + } + else { + envRespHdlr.appendTLV((byte)0x00, (byte)0x00); + } + + envRespHdlr.post(true); + + hasBeenTriggered = false; + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/Test_Api_2_Tkr_Drfes_Bss_Bsb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/Test_Api_2_Tkr_Drfes_Bss_Bsb.java new file mode 100644 index 0000000000000000000000000000000000000000..c2536b74c9ecb0900cd5478cfaaf2db7a3835c11 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/Test_Api_2_Tkr_Drfes_Bss_Bsb.java @@ -0,0 +1,288 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 2 + * Test source for ToolkitRegistry interface + * deregisterFileEvent() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_drfes_bss_bsb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Drfes_Bss_Bsb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_drfes_bss_bsb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + + static final String MF = "3F00"; + static final String ADF = "7FFF"; + static final String DF_TEST = "7F4A"; + static final String DF_SUB_TEST = "5F10"; + static final String EF_TAA = "4F10"; + static final String EF_TARU = "6F03"; + static final String EF_CARU = "6F09"; + static final String EF_LARU = "6F0C"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Drfes_Bss_Bsb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00"); // LV ADF1 access domain DAP + + // test script + test.reset(); + response = test.terminalProfileSession("09030120"); + + + /** Testcase 1 ***************************************** + * Deregister EF under MF + *******************************************************/ + + test.unrecognizedEnvelope(); + + // update binary EF_TARU and check that applet is correctly triggered + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_CARU, true); + result &= modifyEFandCheck(MF, EF_LARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, false); + result &= modifyEFandCheck(MF, EF_CARU, false); + result &= modifyEFandCheck(MF, EF_LARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_LARU, false); + + test.unrecognizedEnvelope(); + + + /** Testcase 2 ***************************************** + * Deregister DF under MF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + + /** Testcase 3 ***************************************** + * Deregister EF does not affect parent DF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_LARU, true); + + + /** Testcase 4 ***************************************** + * Deregister EF under ADF1 + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_CARU, true); + result &= modifyEFandCheck(ADF, EF_LARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, false); + result &= modifyEFandCheck(ADF, EF_CARU, false); + result &= modifyEFandCheck(ADF, EF_LARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_LARU, false); + + test.unrecognizedEnvelope(); + + + /** Testcase 5 ***************************************** + * Deregister DF does not affect child EF (under ADF1) + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + + /** Testcase 6 ***************************************** + * Deregister EF does not affect parent DF (under ADF1) + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_LARU, true); + + + /** Testcase 7 - 20 ********************************** + * 7. NullPointerException Exception + * 8. sOffset1 >= baFileList.length + * 9. sOffset1 < 0 + * 10. sLength1 > baFileList.length + * 11. sOffset1 + sLength1 > baFileList.length + * 12. sLength1 < 0 + * 13. sOffset2 >= baFileList.length + * 14. sOffset2 < 0 + * 15. sLength2 > baFileList.length + * 16. sOffset2 + sLength2 > baFileList.length + * 17. ILLEGAL_VALUE Exception + * 18. EVENT_MENU_SELECTION not allowed + * 19. EVENT_MENU_SELECTION_HELP_REQUEST not allowed + * 20. EVENT_TIMER_EXPIRATION not allowed + * 21. EVENT_STATUS_COMMAND not allowed + * 22. EVENT_NOT_SUPPORTED Exception + *****************************************************/ + + for (int i=7; i<=22; i++ ) { + test.unrecognizedEnvelope(); + } + + + + /***************************************************** + * Restore modified files + *****************************************************/ + + // restore EF_CARU under ADF + test.selectApplication(AID_ADF_1); + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + // restore EF_CARU under MF + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + + /***************************************************** + * Finish test + *****************************************************/ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "16CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } + + + /** + * Check the File List which caused the latest EXTERNAL_FILE_UDPATE + * and compare it whith the File List given in parameter. + * If the applet has not been triggered it will return "000100" + */ + + private boolean appletTriggered(String data) { + response = test.envelopeCallControlByNAA(); + return response.checkData(data); + } + + + /** + * Perform an action on the specified EF in order to test + * if the test applet is triggered with an EXTERNAL_FILE_UDPATE event. + */ + + private boolean modifyEFandCheck(String mfadf, String fid, boolean shouldTrigger) { + + // select correct file + if (mfadf == ADF) test.selectApplication(AID_ADF_1); + test.selectFile(mfadf); + test.selectFile(DF_TEST); + if (fid == EF_TAA) test.selectFile(DF_SUB_TEST); + test.selectFile(fid); + + // modify the EF + if (fid == EF_CARU) test.increase("000001"); + else if (fid == EF_LARU) test.updateRecord("01","04","55555555"); + else test.updateBinary("0000", "FFFFFF"); + + // create the string to pass to appletTriggered() + String checkString = ("01" + MF); + if (mfadf == ADF) checkString += ADF; + + if (!shouldTrigger) checkString = "000100"; + else if (fid == EF_TARU) checkString += (DF_TEST + EF_TARU); + else if (fid == EF_CARU) checkString += (DF_TEST + EF_CARU); + else if (fid == EF_LARU) checkString += (DF_TEST + EF_LARU); + else if (fid == EF_TAA) checkString += (DF_TEST + DF_SUB_TEST + EF_TAA); + + // return the result of the triggering + return appletTriggered(checkString); + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3028bdce9bba99fcd6f8b42956aa6287ed10e9ed --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_drfes_bss_bsb.Api_2_Tkr_Drfes_Bss_Bsb_1 +uicc.test.toolkit.api_2_tkr_drfes_bss_bsb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/javacard/api_2_tkr_drfes_bss_bsb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/javacard/api_2_tkr_drfes_bss_bsb.cap new file mode 100644 index 0000000000000000000000000000000000000000..26abc8b1691ae2d1de9426fe0b2a9140bd8fb768 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfes_bss_bsb/javacard/api_2_tkr_drfes_bss_bsb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/Api_2_Tkr_Drfeso_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/Api_2_Tkr_Drfeso_1.java new file mode 100644 index 0000000000000000000000000000000000000000..f4cd80ba973064781936d64174e528c9d9cbf960 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/Api_2_Tkr_Drfeso_1.java @@ -0,0 +1,456 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_drfeso; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.access.*; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, registerFileEvent() method + * applet 1 + */ +public class Api_2_Tkr_Drfeso_1 extends TestToolkitApplet { + + private boolean bRes = true; + private byte callNb = 1; + + private byte[] adf1Aid = null; + private FileView uiccFileView = null; + private FileView adf1FileView = null; + + private boolean hasBeenTriggered = false; + private byte[] baFileList = null; + private short sFileListLength = 0; + + private byte[] baFileList1 = { + (byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x0C + }; + + private byte[] baFileList2 = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList4 = { + (byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x0C + }; + + private byte[] baFileList5 = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A + }; + + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Drfeso_1() { + baFileList = new byte[16]; + adf1Aid = new byte[16]; + UICCTestConstants uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1,(short)0,adf1Aid,(short)0,(short)adf1Aid.length); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Drfeso_1 thisApplet = new Api_2_Tkr_Drfeso_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialize the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register to EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + switch (callNb++) { + + /** Testcase 1 ***************************************** + * Deregister EF under MF + *******************************************************/ + + case 1: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1, + (short) 0, + (short) baFileList1.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 2: + try { + uiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + uiccFileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 3: + try { + uiccFileView.select(UICCTestConstants.FID_EF_CARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 4: + try { + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + uiccFileView.select(UICCTestConstants.FID_EF_LARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 5: + try { + bRes &= !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + } + catch (Exception e) { + bRes=false; + } + + reportTestOutcome((byte) 1, bRes); + break; + + + /** Testcase 2 ***************************************** + * Deregister DF does not affect child EF + *******************************************************/ + + case 6: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList2, (short) 0, (short) baFileList2.length, + null, (short) 0, (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 7: + try { + uiccFileView.select(UICCTestConstants.FID_MF); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + uiccFileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + + reportTestOutcome((byte) 2, bRes); + break; + + + /** Testcase 3 ***************************************** + * Deregister EF does not affect parent DF + *******************************************************/ + + case 8: + try { + bRes = true; + uiccFileView.select(UICCTestConstants.FID_MF); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 9: + try { + uiccFileView.select(UICCTestConstants.FID_MF); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + uiccFileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + + reportTestOutcome((byte) 3, bRes); + break; + + + /** Testcase 4 ***************************************** + * Deregister EF under ADF1 + *******************************************************/ + + case 10: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList4, (short) 0, (short) baFileList4.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + case 11: + try { + adf1FileView = UICCSystem.getTheFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + adf1FileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 12: + try { + adf1FileView.select(UICCTestConstants.FID_EF_CARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 13: + try { + adf1FileView.select(UICCTestConstants.FID_EF_LARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + + reportTestOutcome((byte) 4, bRes); + break; + + + /** Testcase 5 ***************************************** + * Deregister DF does not affect child EF (under ADF1) + *******************************************************/ + case 14: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList5, (short) 0, (short) baFileList5.length, + adf1Aid, (short) 0, (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + break; + + + case 15: + try { + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + + reportTestOutcome((byte) 5, bRes); + break; + + + /** Testcase 6 ***************************************** + * Deregister EF does not affect parent DF (under ADF1) + *******************************************************/ + + case 16: + try { + bRes = true; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + + case 17: + try { + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + adf1FileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 6, bRes); + break; + + + /** Testcase 7 ***************************************** + * NullPointerException Exception + *******************************************************/ + + case 18: + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, null); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) {} + + reportTestOutcome((byte) 7, bRes); + + + /** Testcase 8 ***************************************** + * EVENT_MENU_SELECTION not allowed + *******************************************************/ + + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_MENU_SELECTION, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 8, bRes); + + /** Testcase 9 ***************************************** + * EVENT_MENU_SELECTION_HELP_REQUEST not allowed + *******************************************************/ + + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_MENU_SELECTION_HELP_REQUEST, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 9, bRes); + + /** Testcase 10 **************************************** + * EVENT_TIMER_EXPIRATION not allowed + *******************************************************/ + + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_TIMER_EXPIRATION, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 10, bRes); + + + /** Testcase 11 ***************************************** + * EVENT_STATUS_COMMAND not allowed + *******************************************************/ + + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_STATUS_COMMAND, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 11, bRes); + + + /** Testcase 12 ***************************************** + * EVENT_NOT_SUPPORTED Exception + *******************************************************/ + + try { + bRes = false; + obReg.deregisterFileEvent(EVENT_PROFILE_DOWNLOAD, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_SUPPORTED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 12, bRes); + + } + } + + else if (event == EVENT_EXTERNAL_FILE_UPDATE) { + sFileListLength = EnvelopeHandlerSystem.getTheHandler().findAndCopyValue((byte)0x92, baFileList, (short)0); + hasBeenTriggered = true; + } + + else if (event == EVENT_CALL_CONTROL_BY_NAA) { + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (hasBeenTriggered) { + envRespHdlr.appendArray(baFileList, (short) 0, (short) sFileListLength); + } + else { + envRespHdlr.appendTLV((byte)0x00, (byte)0x00); + } + + envRespHdlr.post(true); + + hasBeenTriggered = false; + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/Test_Api_2_Tkr_Drfeso.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/Test_Api_2_Tkr_Drfeso.java new file mode 100644 index 0000000000000000000000000000000000000000..3271485ab9f1eff4ae372b4cb0e92aed6c4521d5 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/Test_Api_2_Tkr_Drfeso.java @@ -0,0 +1,274 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 2 + * Test source for ToolkitRegistry interface + * deregisterFileEvent() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_drfeso; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Drfeso extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_drfeso"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + + static final String MF = "3F00"; + static final String ADF = "7FFF"; + static final String DF_TEST = "7F4A"; + static final String EF_TARU = "6F03"; + static final String EF_CARU = "6F09"; + static final String EF_LARU = "6F0C"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Drfeso() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00"); // LV ADF1 access domain DAP + + // test script + test.reset(); + response = test.terminalProfileSession("09030120"); + + + /** Testcase 1 ***************************************** + * Deregister EF under MF + *******************************************************/ + + test.unrecognizedEnvelope(); + + // update binary EF_TARU and check that applet is correctly triggered + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_CARU, true); + result &= modifyEFandCheck(MF, EF_LARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, false); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_CARU, false); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_LARU, false); + + test.unrecognizedEnvelope(); + + + /** Testcase 2 ***************************************** + * Deregister DF under MF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + + /** Testcase 3 ***************************************** + * Deregister EF does not affect parent DF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_LARU, true); + + + /** Testcase 4 ***************************************** + * Deregister EF under ADF1 + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_CARU, true); + result &= modifyEFandCheck(ADF, EF_LARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, false); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_CARU, false); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_LARU, false); + + + /** Testcase 5 ***************************************** + * Deregister DF does not affect child EF (under ADF1) + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + + /** Testcase 6 ***************************************** + * Deregister EF does not affect parent DF (under ADF1) + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_LARU, true); + + + + /******************************************************* + * Restore EF_CARU under MF and ADF + *******************************************************/ + + // restore EF_CARU + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + test.selectApplication(AID_ADF_1); + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + + /** Testcase 7 - 12 ********************************** + * 7. NullPointerException Exception + * 8. EVENT_MENU_SELECTION not allowed + * 9. EVENT_MENU_SELECTION_HELP_REQUEST not allowed + * 10. EVENT_TIMER_EXPIRATION not allowed + * 11. EVENT_STATUS_COMMAND not allowed + * 12. EVENT_NOT_SUPPORTED Exception + *****************************************************/ + + test.unrecognizedEnvelope(); + + + /******************************************************* + * Finish test + *******************************************************/ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } + + + /** + * Check the File List which caused the latest EXTERNAL_FILE_UDPATE + * and compare it whith the File List given in parameter. + * If the applet has not been triggered it will return "000100" + */ + + private boolean appletTriggered(String data) { + response = test.envelopeCallControlByNAA(); + return response.checkData(data); + } + + + /** + * Perform an action on the specified EF in order to test + * if the test applet is triggered with an EXTERNAL_FILE_UDPATE event. + */ + + private boolean modifyEFandCheck(String mfadf, String fid, boolean shouldTrigger) { + + // select correct file + if (mfadf == ADF) test.selectApplication(AID_ADF_1); + test.selectFile(mfadf); + test.selectFile(DF_TEST); + test.selectFile(fid); + + // modify the EF + if (fid == EF_TARU) test.updateBinary("0000", "FFFFFF"); + else if (fid == EF_LARU) test.updateRecord("01","04","55555555"); + else if (fid == EF_CARU) test.increase("000001"); + + + // create the string to pass to appletTriggered() + String checkString = ("01" + MF); + if (mfadf == ADF) checkString += ADF; + + if (!shouldTrigger) checkString = "000100"; + else if (fid == EF_TARU) checkString += (DF_TEST + EF_TARU); + else if (fid == EF_CARU) checkString += (DF_TEST + EF_CARU); + else if (fid == EF_LARU) checkString += (DF_TEST + EF_LARU); + + // return the result of the triggering + return appletTriggered(checkString); + } + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6675683db176a9dd7f308360b015ff2736930c75 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_drfeso.Api_2_Tkr_Drfeso_1 +uicc.test.toolkit.api_2_tkr_drfeso +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/javacard/api_2_tkr_drfeso.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/javacard/api_2_tkr_drfeso.cap new file mode 100644 index 0000000000000000000000000000000000000000..619ac33680a1024bf28157f9e8a550e2a1e3e471 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_drfeso/javacard/api_2_tkr_drfeso.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/Api_2_Tkr_Emet_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/Api_2_Tkr_Emet_1.java new file mode 100644 index 0000000000000000000000000000000000000000..203f13ad27cade9dcbab17cb2937658877770f02 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/Api_2_Tkr_Emet_1.java @@ -0,0 +1,212 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_emet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, enableMenuEntry() method + * applet 1 + */ +public class Api_2_Tkr_Emet_1 extends TestToolkitApplet { + + boolean bRes = false; + byte testCaseNb = (byte) 5; + + private static byte [] MenuInit = {(byte) 'I', (byte) 'n', (byte) 'i', (byte) 't'}; + private byte callNb = (byte) 0; + private byte resultat = (byte) 0; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Emet_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Emet_1 thisApplet = new Api_2_Tkr_Emet_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE and EVENT_MENU_SELECTION + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short)4, (byte) 0, false, + (byte) 0, (short) 0); + + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short)4, (byte) 0, false, + (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + short i; + + // Increasing the trigger counter. + ++callNb; + + switch(callNb) { + case (byte)1: + // ----------------------------------------------------------------- + // Test Case 1 : Check menu state before enabling a previously disabled + // entry not registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + + testCaseNb = (byte)1; + bRes = false; + + bRes = obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + if (bRes) { + bRes = false; + try { + obReg.disableMenuEntry((byte)0x01); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + } + + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)2: + // ----------------------------------------------------------------- + // Test case 2 : Check menu state after enabling a previously disabled + // entry not registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + + testCaseNb = (byte)2; + bRes = false; + + + try { + obReg.enableMenuEntry((byte)0x01); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && + obReg.isEventSet(EVENT_MENU_SELECTION) && + !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte) 3 : + // ----------------------------------------------------------------- + // Test Case 3 : Check menu state before enabling a previously enabled + // entry registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + + testCaseNb = (byte)3; + bRes = false; + + try { + obReg.changeMenuEntry((byte)0x02, MenuInit, (short)0, (short)4, + (byte)0, true, (byte)0, (short)0); + bRes = true; + } + catch(Exception e) { + bRes = false; + } + + bRes = bRes && + obReg.isEventSet(EVENT_MENU_SELECTION) && + obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + if (bRes) { + bRes = false; + try { + obReg.disableMenuEntry((byte)0x02); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + } + + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)4: + // ----------------------------------------------------------------- + // Test case 4 : Check menu state after enabling a previously enabled + // entry registered to EVENT_MENU_SELECTION_HELP_REQUEST + // ----------------------------------------------------------------- + + testCaseNb = (byte)4; + bRes = false; + + try { + obReg.enableMenuEntry((byte)0x02); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && + obReg.isEventSet(EVENT_MENU_SELECTION) && + obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)5: + // ----------------------------------------------------------------- + // Test Case 5 : Enabling invalid entries + // ----------------------------------------------------------------- + + testCaseNb = (byte)5; + bRes = false; + + try { + obReg.enableMenuEntry((byte)0); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + + if (bRes) { + for (i = 3; (i<256) && bRes;i++) { + bRes = false; + try { + obReg.enableMenuEntry((byte)i); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { + bRes = false; + } + } + } + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/Test_Api_2_Tkr_Emet.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/Test_Api_2_Tkr_Emet.java new file mode 100644 index 0000000000000000000000000000000000000000..fe6662e08e5bdf445aee63047e27d8f5ce7b6366 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/Test_Api_2_Tkr_Emet.java @@ -0,0 +1,119 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * enableMenuEntry() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_emet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Emet extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_emet"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Emet() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800C" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "02" + // V Maximum number of menu entries + "01010202" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + response = test.terminalProfile("09010020"); + result = response.checkSw("9124"); + response = test.fetch("24"); + result &= response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F05 01496E69 748F0502" + + "496E6974"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 1 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911D"); + response = test.fetch("1D"); + result &= response.checkData("D01B8103 01250082 02818285 09554943" + + "43205445 53548F05 02496E69 74"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 2 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9124"); + response = test.fetch("24"); + result &= response.checkData("D0228103 01250082 02818285 09554943" + + "43205445 53548F05 01496E69 748F0502" + + "496E6974"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 3 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("911D"); + response = test.fetch("1D"); + result &= response.checkData("D01B8103 01250082 02818285 09554943" + + "43205445 53548F05 01496E69 74"); + response = test.terminalResponse("81030125 00820282 81830100"); + result &= response.checkSw("9000"); + + // test case 4 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9124"); + response = test.fetch("24"); + result &= response.checkData("D0228103 01258082 02818285 09554943" + + "43205445 53548F05 01496E69 748F0502" + + "496E6974"); + response = test.terminalResponse("81030125 80820282 81830100"); + result &= response.checkSw("9000"); + + // test case 5 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "05CCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..0820bc5169fe8790db3a4d193b90e5ec3e8a1601 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_emet.Api_2_Tkr_Emet_1 +uicc.test.toolkit.api_2_tkr_emet +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/javacard/api_2_tkr_emet.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/javacard/api_2_tkr_emet.cap new file mode 100644 index 0000000000000000000000000000000000000000..2dfb7daa48212e4b2c94de940b1ec1bb613c3c32 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_emet/javacard/api_2_tkr_emet.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/Api_2_Tkr_Gpol_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/Api_2_Tkr_Gpol_1.java new file mode 100644 index 0000000000000000000000000000000000000000..246dc9e04fa01041c6e17772524ae007ccf9e9a0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/Api_2_Tkr_Gpol_1.java @@ -0,0 +1,129 @@ +package uicc.test.toolkit.api_2_tkr_gpol; + +import uicc.test.util.*; +import uicc.toolkit.*; +import javacard.framework.*; + + +/** + * uicc.toolkit package, ToolkitRegistry interface, getPollInterval() method + * applet 1 + */ +public class Api_2_Tkr_Gpol_1 extends TestToolkitApplet { + boolean bRes; + byte testCaseNb; + + // Trigger number + byte callNb = (byte) 0; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Gpol_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte[] bArray, short bOffset, byte bLength) { + // Create a new applet instance + Api_2_Tkr_Gpol_1 thisApplet = new Api_2_Tkr_Gpol_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short) (bOffset + 1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + short i; + short pollInterval; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + callNb++; + + switch (callNb) { + /** Test Case 1 : + * Applet isn't registered to EVENT_STATUS_COMMAND + */ + case (byte) 1: + testCaseNb = (byte) 1; + reportTestOutcome(testCaseNb, obReg.getPollInterval() == 0); + + break; + + /** Test Case 2 : + * Requesting max duration + */ + case (byte) 2: + testCaseNb = (byte) 2; + bRes = false; + + try { + obReg.requestPollInterval((short) 15300); + bRes = true; + } catch (Exception e) { + bRes = false; + } + + break; + + case (byte) 3: + pollInterval = obReg.getPollInterval(); + reportTestOutcome(testCaseNb, bRes && (pollInterval > 0) && (pollInterval < 15301)); + + break; + + /** Test Case 3 : + * Requesting System Duration + */ + case (byte) 4: + testCaseNb = (byte) 3; + bRes = false; + + try { + obReg.requestPollInterval(POLL_SYSTEM_DURATION); + bRes = true; + } catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + break; + + case (byte) 5: + pollInterval = obReg.getPollInterval(); + reportTestOutcome(testCaseNb, bRes && (pollInterval > 0) && (pollInterval < 15301)); + + break; + + /** Test Case 4 : + * Requesting no Duration + */ + case (byte) 6: + testCaseNb = (byte) 4; + bRes = false; + + try { + obReg.requestPollInterval(POLL_NO_DURATION); + bRes = true; + } catch (Exception e) { + bRes = false; + } + + break; + + case (byte) 7: + reportTestOutcome(testCaseNb, bRes && (obReg.getPollInterval() == 0)); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/Test_Api_2_Tkr_Gpol.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/Test_Api_2_Tkr_Gpol.java new file mode 100644 index 0000000000000000000000000000000000000000..5166137bd69ac52a7708a8ec86e3f5808e465c2f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/Test_Api_2_Tkr_Gpol.java @@ -0,0 +1,109 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * getPollInterval() method + */ + +package uicc.test.toolkit.api_2_tkr_gpol; + +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + + +public class Test_Api_2_Tkr_Gpol extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_gpol"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Gpol() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09017020"); + + /** Test case 1 + * Applet isn't registered to EVENT_STATUS_COMMAND. + */ + test.unrecognizedEnvelope(); + + /** Test case 2 + * Requesting max duration. + */ + response = test.unrecognizedEnvelope(); + result &= response.checkSw("910F"); + response = test.fetch("0F"); + test.terminalResponse("81030103 00820282 81830100 840200FF"); + test.reset(); + response = test.terminalProfile("09017020"); + result &= response.checkSw("910F"); + response = test.fetch("0F"); + test.terminalResponse("81030103 00820282 81830100 840200FF"); + test.unrecognizedEnvelope(); + + /** Test case 3 + * Requesting system duration. + */ + response = test.unrecognizedEnvelope(); + result &= response.checkSw("910F"); + response = test.fetch("0F"); + test.terminalResponse("81030103 00820282 81830100 8402011E"); + test.reset(); + response = test.terminalProfile("09017020"); + result &= response.checkSw("910F"); + response = test.fetch("0F"); + test.terminalResponse("81030103 00820282 81830100 84020175"); + test.unrecognizedEnvelope(); + + /** Test case 4 + * Requesting no Duration. + */ + response = test.unrecognizedEnvelope(); + result &= response.checkSw("910B"); + response = test.fetch("0B"); + test.terminalResponse("81030104 00820282 81830100"); + test.reset(); + response = test.terminalProfile("09017020"); + result &= response.checkSw("9000"); + test.unrecognizedEnvelope(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "04CCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..3a0fe79ec32448a410734fcdaa55d32b9bf4c598 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_gpol.Api_2_Tkr_Gpol_1 +uicc.test.toolkit.api_2_tkr_gpol +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/javacard/api_2_tkr_gpol.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/javacard/api_2_tkr_gpol.cap new file mode 100644 index 0000000000000000000000000000000000000000..c36742f54b4fc1a3799355692514e632b1d0d3a0 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_gpol/javacard/api_2_tkr_gpol.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Api_2_Tkr_Ievs_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Api_2_Tkr_Ievs_1.java new file mode 100644 index 0000000000000000000000000000000000000000..e9e5dc276713add71bce98135cf9d31ad027c508 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Api_2_Tkr_Ievs_1.java @@ -0,0 +1,276 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_ievs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, isEventSet() method + * applet 1 + */ +public class Api_2_Tkr_Ievs_1 extends TestToolkitApplet { + + // Not allowed events for the setEvent() method + private static short[] NOT_ALLOWED_SET_EVENTS = {EVENT_MENU_SELECTION, EVENT_MENU_SELECTION_HELP_REQUEST, + EVENT_TIMER_EXPIRATION, EVENT_STATUS_COMMAND, + EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION, + EVENT_EXTERNAL_FILE_UPDATE}; + + // Not supported events for the setEvent() method + private static short NOT_SUPPORTED_SETEVENT_10 = 10; + private static short NOT_SUPPORTED_SETEVENT_24 = 24; + + // Event value range + private static short MIN_EVENT_NB = 7; + private static short MAX_EVENT_NB = 29; + + // Events allowed and supported for isEventSet() method + private static short MAX_EVENT = 21; // 27 events - 6 not allowed events + private short[] EventList = new short[MAX_EVENT]; + + private static byte[] MenuEntry1 = {(byte)'T', (byte)'e', (byte)'s', (byte)'t', (byte)'1'}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Ievs_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Ievs_1 thisApplet = new Api_2_Tkr_Ievs_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION and EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.initMenuEntry(MenuEntry1, (short)0, (short)MenuEntry1.length, (byte)0, + false, (byte)0, (short)0); + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + /** + * Method called by the processToolkit() method to know if event + * is an allowed event for the setEvent() method + */ + private boolean isEventAllowed(short event) { + boolean allowed = true; + + for(short i = 0; (i < NOT_ALLOWED_SET_EVENTS.length) && (allowed); i++) { + allowed = (NOT_ALLOWED_SET_EVENTS[i] != event); + } + return allowed; + } + + /** + * Method called by the processToolkit() method to know if event + * is a supported event for the setEvent() method + */ + private boolean isEventSupported(short event) { + return (((event != NOT_SUPPORTED_SETEVENT_10) + &&(event != NOT_SUPPORTED_SETEVENT_24) + && (event >= MIN_EVENT_NB) + && (event <= MAX_EVENT_NB)) + || (event == EVENT_UNRECOGNIZED_ENVELOPE) + || (event == EVENT_PROFILE_DOWNLOAD) + || (event == EVENT_PROACTIVE_HANDLER_AVAILABLE) + || (event == EVENT_EXTERNAL_FILE_UPDATE) + || (event == EVENT_APPLICATION_DESELECT) + || (event == EVENT_FIRST_COMMAND_AFTER_ATR)); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes; + byte testCaseNb; + short j=0; + + // Build the allowed and supported events list + for (short i = MIN_EVENT_NB; i <= MAX_EVENT_NB; i++) { + if ((this.isEventAllowed(i)) && (this.isEventSupported(i))) { + EventList[j] = i; + j++; + } + } + EventList[j++] = EVENT_UNRECOGNIZED_ENVELOPE; + EventList[j++] = EVENT_PROFILE_DOWNLOAD; + EventList[j++] = EVENT_PROACTIVE_HANDLER_AVAILABLE; + EventList[j++] = EVENT_APPLICATION_DESELECT; + EventList[j] = EVENT_FIRST_COMMAND_AFTER_ATR; + + // ----------------------------------------------------------------- + // Test Case 1 : Applet calls isEventSet() for each events allowed and supported + // except EVENT_UNRECOGNIZED_ENVELOPE and EVENT_MENU_SELECTION. + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = true; + + /* all events from -1, 1, 7 to 9, 11 to 23, 25 to 29, 123, 124, 126, 127 except -1 and 7 */ + for (short i = 0; (i < (short)(MAX_EVENT)) && bRes; i++) { + if ((EventList[i] != EVENT_UNRECOGNIZED_ENVELOPE) && (EventList[i] != EVENT_MENU_SELECTION)) { + bRes = !obReg.isEventSet(EventList[i]); + } + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : call isEventSet(EVENT_UNRECOGNIZED_ENVELOPE) + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + + bRes = obReg.isEventSet(EVENT_UNRECOGNIZED_ENVELOPE); + + reportTestOutcome(testCaseNb, bRes); + + + // ----------------------------------------------------------------- + // Test Case 3 : call isEventSet(EVENT_MENU_SELECTION) + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + + bRes = obReg.isEventSet(EVENT_MENU_SELECTION); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4: Call clearEvent() then isEventSet() for EVENT_UNRECOGNIZED_ENVELOPE + // ----------------------------------------------------------------- + testCaseNb = (byte)4; + bRes = false; + + try { + obReg.clearEvent(EVENT_UNRECOGNIZED_ENVELOPE); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && !obReg.isEventSet(EVENT_UNRECOGNIZED_ENVELOPE); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 5 : For each SUPPORTED and ALLOWED event for setEvent(), + // applet calls setEvent() and isEventSet() methods + // ----------------------------------------------------------------- + testCaseNb = (byte)5; + bRes = true; + try { + for (short i = 0; (i < MAX_EVENT) && bRes;i++) { + + bRes = false; + if ((this.isEventAllowed(EventList[i])) + && (this.isEventSupported(EventList[i]))) { + + obReg.setEvent(EventList[i]); + bRes = obReg.isEventSet(EventList[i]); + + // Clear the setEvent + obReg.clearEvent(EventList[i]); + } else { + bRes = true; + } + } + } + catch (Exception e) { // No exception should be thrown + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6 :For EVENT_MENU_SELECTION_HELP_REQUEST call: + // 1 - isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // 2 - changeMenuEntry with help supported + // 3 - isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // ----------------------------------------------------------------- + + testCaseNb = (byte)6; + + bRes = !obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + try { + obReg.changeMenuEntry((byte) 1, MenuEntry1, (short)0, (short)MenuEntry1.length, + (byte)0, true, (byte)0, (short)0); + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7 : For EVENT_TIMER_EXPIRATION, call: + // 1 - isEventSet(EVENT_TIMER_EXPIRATION) + // 2 - allocateTimer() + // 3 - isEventSet(EVENT_TIMER_EXPIRATION) + // ----------------------------------------------------------------- + testCaseNb = (byte)7; + + bRes = !obReg.isEventSet(EVENT_TIMER_EXPIRATION); + + try { + obReg.allocateTimer(); + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && obReg.isEventSet(EVENT_TIMER_EXPIRATION); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 8 : For Event EVENT_STATUS_COMMAND, call: + // 1 - isEventSet(EVENT_STATUS_COMMAND) + // 2 - requestPollInterval(POLL_SYSTEM_DURATION) + // 3 - isEventSet(EVENT_STATUS_COMMAND) + // ----------------------------------------------------------------- + testCaseNb = (byte)8; + bRes = !obReg.isEventSet(EVENT_STATUS_COMMAND); + + try { + obReg.requestPollInterval(POLL_SYSTEM_DURATION); + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && obReg.isEventSet(EVENT_STATUS_COMMAND); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 9 : For Event EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION , call: + // 1 - isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) + // 2 - allocateServiceIdentifier() + // 3 - isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) + // ----------------------------------------------------------------- + testCaseNb = (byte)9; + bRes = !obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + + try { + obReg.allocateServiceIdentifier(); + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Api_2_Tkr_Ievs_2.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Api_2_Tkr_Ievs_2.java new file mode 100644 index 0000000000000000000000000000000000000000..d9357d3e1260a20dbe00b52b647911a8831a3b57 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Api_2_Tkr_Ievs_2.java @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_ievs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, isEventSet() method + * applet 2 + */ +public class Api_2_Tkr_Ievs_2 extends TestToolkitApplet { + + private static byte[] MenuEntry2 = {(byte)'T', (byte)'e', (byte)'s', (byte)'t', (byte)'2'}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Ievs_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Ievs_2 thisApplet = new Api_2_Tkr_Ievs_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuEntry2, (short)0, (short)MenuEntry2.length, (byte)0, + false, (byte)0, (short)0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + // Result of tests + boolean bRes = false; + + // Number of tests + byte testCaseNb = (byte)0x01; + + // test case 10: check applet2 is triggered + bRes = !obReg.isEventSet(EVENT_UNRECOGNIZED_ENVELOPE); + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Test_Api_2_Tkr_Ievs.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Test_Api_2_Tkr_Ievs.java new file mode 100644 index 0000000000000000000000000000000000000000..b5a6846a4762b10bea57df7e686625f8bab92484 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/Test_Api_2_Tkr_Ievs.java @@ -0,0 +1,93 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * isEventSet() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_ievs; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Ievs extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_ievs"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 20020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 20020102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Ievs() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "01" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0102" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("090110"); + + // test case 1 to 9: trigger applet1 + test.envelopeMenuSelection("900101",""); + + // test case 10: trigger applet2 + test.envelopeMenuSelection("900102",""); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "09CCCCCC CCCCCCCC CCCC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..00b56cac024a0f8c5e46e292cf201000facdbd71 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x02:0x00:0x01 uicc.test.toolkit.api_2_tkr_ievs.Api_2_Tkr_Ievs_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_ievs.Api_2_Tkr_Ievs_1 +uicc.test.toolkit.api_2_tkr_ievs +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/javacard/api_2_tkr_ievs.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/javacard/api_2_tkr_ievs.cap new file mode 100644 index 0000000000000000000000000000000000000000..ae1d86798be3051cfeb7803752ccee4f85d38082 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_ievs/javacard/api_2_tkr_ievs.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/Api_2_Tkr_Imet_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/Api_2_Tkr_Imet_1.java new file mode 100644 index 0000000000000000000000000000000000000000..0cdf674a337ed00763927380ac87a8b2093f242e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/Api_2_Tkr_Imet_1.java @@ -0,0 +1,476 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_imet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, initMenuEntry() method + * applet 1 + */ +public class Api_2_Tkr_Imet_1 extends TestToolkitApplet { + + private static byte[] MenuEntry = {(byte)'T', (byte)'o', (byte)'o', (byte)'l', + (byte)'k', (byte)'i', (byte)'t', (byte)'T', + (byte)'e', (byte)'s', (byte)'t'}; + + private static byte[] MenuEntryImpossible = {(byte)'T', (byte)'o', (byte)'o', (byte)'l', + (byte)'k', (byte)'i', (byte)'t', (byte)'T', + (byte)'e', (byte)'s', (byte)'t', (byte)' ', + (byte)'I', (byte)'m', (byte)'p', (byte)'o', + (byte)'s', (byte)'s', (byte)'i', (byte)'b', + (byte)'l', (byte)'e'}; + + private byte[] MenuTest = {(byte)'T', (byte)'O', (byte)'O', (byte)'L', + (byte)'K', (byte)'I', (byte)'T', (byte)' ', + (byte)'T', (byte)'E', (byte)'S', (byte)'T', + (byte)' ', (byte)'1'}; + + private static byte[] MenuOffset = {(byte)'1', (byte)'2', (byte)'3', (byte)'4', + (byte)'5', (byte)'6', (byte)'7', (byte)'T', + (byte)'O', (byte)'O', (byte)'L', (byte)'K', + (byte)'I', (byte)'T', (byte)' ', (byte)'T', + (byte)'E', (byte)'S', (byte)'T', (byte)' ', + (byte)'2'}; + + private byte result = (byte)0; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Imet_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + boolean bRes; + // Number of tests + byte testCaseNb = (byte)23; + + // Create a new applet instance + Api_2_Tkr_Imet_1 thisApplet = new Api_2_Tkr_Imet_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // ----------------------------------------------------------------- + // Test Case 1: NULL as parameter to menuEntry + // Shall throw a NullPointerException + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(null, (short)0, (short)0, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2: Offset = menuEntry.length + // MenuEntry = "ToolkitTest" + // Offset = 12 + // Length = 0 + // Shall throw ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)12, (short)0, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3: Offset < 0 + // MenuEntry = "ToolkitTest" + // Offset = -1 + // Shall throw ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)-1, (short)0, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4: Offset = 255 + // MenuEntry = "ToolkitTest" + // Offset = 255 + // Length = 11 + // Shall throw ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)4; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)255, (short)11, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 5: Length = menuEntry.length+1 + // MenuEntry = "ToolkitTest" + // Offset = 0 + // Length = 12 + // Shall throw ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)5; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)0, (short)12, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6: Length < 0 + // MenuEntry = "ToolkitTest" + // Offset = 0 + // Length = -1 + // Shall throw ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)6; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)0, (short)-1, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7: Offset + length > menuEntry.length + // MenuEntry = "ToolkitTest" + // Offset = 11 + // Length = 1 + // Shall throw ArrayIndexOutOfBoundsException + // ----------------------------------------------------------------- + testCaseNb = (byte)7; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)11, (short)1, (byte)0, false, + (byte)0, (short)0); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 8: MenuEntry.length > size allocated at loading for each menu entry + // MenuEntry = "ToolkitTest Impossible" + // Offset = 0 + // Length = 16 + // ALLOWED_LENGTH_EXCEEDED ToolkitException is thrown + // ----------------------------------------------------------------- + testCaseNb = (byte)8; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntryImpossible, (short)0, (short)16, (byte)0, false, + (byte)0, (short)0); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.ALLOWED_LENGTH_EXCEEDED); + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 9: Successful call, MenuEntry is the whole buffer + // 1-MenuEntry = "TOOLKIT TEST 1" + // Offset = 0 + // Length = 14 + // Shall return ID 01 + // 2-isEventSet(EVENT_MENU_SELECTION) + // Shall return true + // ----------------------------------------------------------------- + testCaseNb = (byte)9; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(thisApplet.MenuTest, (short)0, (short)14, (byte)0, false, + (byte)0, (short)0); + bRes = (thisApplet.result == (byte)1); + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION); + + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 10: Successful call, MenuEntry part of a buffer + // 1-MenuEntry = "1234567TOOLKIT TEST 2" + // Offset = 7 + // Length = 14 + // Shall return ID 02 + // 2-isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // Shall return false + // ----------------------------------------------------------------- + testCaseNb = (byte)10; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuOffset, (short)7, (short)14, (byte)0, false, + (byte)0, (short)0); + bRes = thisApplet.result == (byte)2; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && !thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + thisApplet.reportTestOutcome(testCaseNb, bRes); + + + // ----------------------------------------------------------------- + // Test Case 11: Successful call, MenuEntry with help supported + // 1-MenuEntry = "TOOLKIT TEST 3" + // Offset = 0 + // Length = 14 + // Shall return ID 03 + // 2-isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST) + // Shall return true + // ----------------------------------------------------------------- + testCaseNb = (byte)11; + bRes = false; + + thisApplet.MenuTest[13] = (byte)'3'; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(thisApplet.MenuTest, (short)0, (short)14, (byte)0, true, + (byte)0, (short)0); + bRes = thisApplet.result == (byte)3; + } + catch (Exception e) { + bRes = false; + } + + bRes = bRes && thisApplet.obReg.isEventSet(EVENT_MENU_SELECTION_HELP_REQUEST); + + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 12: Successful call, MenuEntry with an icon + // MenuEntry = "TOOLKIT TEST 4" + // Offset = 0 + // Length = 14 + // Shall return ID 04 + // ----------------------------------------------------------------- + testCaseNb = (byte)12; + bRes = false; + + thisApplet.MenuTest[13] = (byte)'4'; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(thisApplet.MenuTest, (short)0, (short)14, (byte)0, false, + (byte)1, (short)1); + bRes = thisApplet.result == (byte)4; + } + catch (Exception e) { + bRes = false; + } + + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 13: Successful call, MenuEntry + // with a next action indication + // MenuEntry = "TOOLKIT TEST 5" + // Offset = 0 + // Length = 14 + // NextAction = 24 [Select Item] + // Shall return ID 05 + // ----------------------------------------------------------------- + testCaseNb = (byte)13; + bRes = false; + + thisApplet.MenuTest[13] = (byte)'5'; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(thisApplet.MenuTest, (short)0, (short)14, (byte)0x24, false, + (byte)0, (short)0); + bRes = thisApplet.result == (byte)5 ; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 14: Successful call, length = 0 + // MenuEntry = "ToolkitTest" + // Offset = 0 + // Length = 0 + // NextAction = 00 + // HelpSupported = false + // IconQualifier = 00 + // IconIdentifier = 00 + // Shall return ID 06 + // ----------------------------------------------------------------- + testCaseNb = (byte)14; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)0, (short)0, (byte)0, false, + (byte)0, (short)0); + bRes = thisApplet.result == (byte)6; + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 15: Initialize more entry than allocated at loading + // MenuEntry = "ToolkitTest" + // Offset = 0 + // Length = 11 + // REGISTRY_ERROR ToolkitException is thrown + // ----------------------------------------------------------------- + testCaseNb = (byte)15; + bRes = false; + + try { + thisApplet.result = thisApplet.obReg.initMenuEntry(MenuEntry, (short)0, (short)11, (byte)0, false, + (byte)0, (short)0); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.REGISTRY_ERROR); + } + catch (Exception e) { + bRes = false; + } + thisApplet.reportTestOutcome(testCaseNb, bRes); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes; + byte testCaseNb; + byte TLV; + byte ItemID; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + // ----------------------------------------------------------------- + // Test Case 16: Dynamic update of the menu stored by the ME + // This test is true by default + // ----------------------------------------------------------------- + testCaseNb = (byte)16; + reportTestOutcome(testCaseNb, true); + } else { + if (event == EVENT_MENU_SELECTION) { + + // ----------------------------------------------------------------- + // Test Cases 17-21 and 23: Check Applet is triggered by + // ENVELOPE(MENU_SELECTION) command + // ----------------------------------------------------------------- + + // find item ID + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + TLV = envHdlr.findTLV(TAG_ITEM_IDENTIFIER, (byte)1); + + if (TLV != TLV_NOT_FOUND) { + ItemID = envHdlr.getValueByte((short)0); + + if ((ItemID > (byte)0) && (ItemID < (byte)6)) { + testCaseNb = (byte)(ItemID + 16); + reportTestOutcome(testCaseNb, true); + } else if (ItemID == (byte)6) { + reportTestOutcome((byte)23, true); + } + } + } else { + + if (event == EVENT_MENU_SELECTION_HELP_REQUEST) { + // ----------------------------------------------------------------- + // Test Case 22 : Check Applet is triggered by + // ENVELOPE(MENU_SELECTION_HELP_REQUEST) command + // Menu Entry ID = 03 + // ----------------------------------------------------------------- + // find item ID + EnvelopeHandler envHdlr = EnvelopeHandlerSystem.getTheHandler(); + TLV = envHdlr.findTLV(TAG_ITEM_IDENTIFIER, (byte)1); + + if (TLV != TLV_NOT_FOUND) { + ItemID = envHdlr.getValueByte((short)0); + testCaseNb = (byte)22; + reportTestOutcome(testCaseNb, ItemID == (byte)3); + } + } + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/Test_Api_2_Tkr_Imet.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/Test_Api_2_Tkr_Imet.java new file mode 100644 index 0000000000000000000000000000000000000000..e8e96aa0d267dc60e55184a740d97edb8929d0a3 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/Test_Api_2_Tkr_Imet.java @@ -0,0 +1,118 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * isEventSet() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_imet; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Imet extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_imet"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Imet() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8014" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "06" + // V Maximum number of menu entries + "01010202 03030404 05050606" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfile("09010020"); + + // test Case 16 + response = test.fetch("76"); + result = response.checkData("D0748103 01258082 02818285 09554943" + + "43205445 53548F0F 01544F4F 4C4B4954" + + "20544553 5420318F 0F02544F 4F4C4B49" + + "54205445 53542032 8F0F0354 4F4F4C4B" + + "49542054 45535420 338F0F04 544F4F4C" + + "4B495420 54455354 20348F0F 05544F4F" + + "4C4B4954 20544553 5420358F 01061806" + + "00000000 2400"); + result &= response.checkSw("9000"); + + response = test.terminalResponse("81030125 80820282 81830100"); + result &= response.checkSw("9000"); + + test.unrecognizedEnvelope(); + result &= response.checkSw("9000"); + + // test case 17 + response = test.envelopeMenuSelection("900101", ""); + result &= response.checkSw("9000"); + + // test case 18 + response = test.envelopeMenuSelection("900102", ""); + result &= response.checkSw("9000"); + + // test case 19 + response = test.envelopeMenuSelection("900103", ""); + result &= response.checkSw("9000"); + + // test case 20 + response = test.envelopeMenuSelection("900104", ""); + result &= response.checkSw("9000"); + + // test case 21 + response = test.envelopeMenuSelection("900105", ""); + result &= response.checkSw("9000"); + + // test case 22 + response = test.envelopeMenuSelection("900103", "9500"); + result &= response.checkSw("9000"); + + // test case 23 + response = test.envelopeMenuSelection("900106", ""); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "17CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..6db8050a8c3c43a531140b7a064651b7c564b6b6 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_imet.Api_2_Tkr_Imet_1 +uicc.test.toolkit.api_2_tkr_imet +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/javacard/api_2_tkr_imet.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/javacard/api_2_tkr_imet.cap new file mode 100644 index 0000000000000000000000000000000000000000..83e0b08963886c7efdbfed80f3e5104fb5e02c31 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_imet/javacard/api_2_tkr_imet.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/Api_2_Tkr_Rgfes_Bss_Bsb_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/Api_2_Tkr_Rgfes_Bss_Bsb_1.java new file mode 100644 index 0000000000000000000000000000000000000000..ec376a8b3778b2842a50e4077a5e345299c5796b --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/Api_2_Tkr_Rgfes_Bss_Bsb_1.java @@ -0,0 +1,875 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rgfes_bss_bsb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, registerFileEvent() method + * applet 1 + */ +public class Api_2_Tkr_Rgfes_Bss_Bsb_1 extends TestToolkitApplet { + + private boolean bRes = true; + private byte callNb = 1; + private boolean hasBeenTriggered = false; + + private byte[] adf1Aid; + private byte[] baADFAid15; + private byte[] baADFAid18; + + private byte[] baFileList; + private short sFileListLength; + + private byte[] baFileList1 = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09 + }; + + private byte[] baFileList2 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList3 = { + (byte)0x02, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x09 + }; + + private byte[] baFileList4 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0xFF, (byte)0x7F,(byte)0x4A + }; + + private byte[] baFileList6 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x5F,(byte)0x16 ,(byte)0x16 + }; + + private byte[] baFileList21 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x6F,(byte)0x03 + }; + + private byte[] baFileList22 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x5F,(byte)0x10 + }; + + private byte[] baFileList23 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x5F,(byte)0x10, (byte)0x4F,(byte)0x16 + }; + + + private byte[] baFileList24 = { + (byte)0x01, + (byte)0x3F,(byte)0x00, (byte)0x7F,(byte)0x4A, (byte)0x5F,(byte)0x16 + }; + + + static final byte FILE_LIST_TAG = (byte) 0x92; + + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Rgfes_Bss_Bsb_1() { + baFileList = new byte[10]; + adf1Aid = new byte[16]; + baADFAid15 = new byte[15]; + baADFAid18 = new byte[18]; + UICCTestConstants uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1,(short)0,adf1Aid,(short)0,(short)adf1Aid.length); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Rgfes_Bss_Bsb_1 thisApplet = new Api_2_Tkr_Rgfes_Bss_Bsb_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialize the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register to EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + switch (callNb++) { + + /** Testcase 1 ***************************************** + * Register EF under MF + *******************************************************/ + + case 1: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1, + (short) 0, + (short) baFileList1.length, + null, + (short) 0, + (byte) 0 ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 2: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList1, + (short) 0, + (short) baFileList1.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 1, bRes); + break; + + /** Testcase 2 ***************************************** + * Register DF under MF + *******************************************************/ + + case 3: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList2, + (short) 0, + (short) baFileList2.length, + null, + (short) 0, + (byte) 0 ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 4: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList2, + (short) 0, + (short) baFileList2.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 2, bRes); + break; + + + /** Testcase 3 ***************************************** + * Register EF under ADF1 + *******************************************************/ + case 5: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList3, + (short) 0, + (short) baFileList3.length, + adf1Aid, + (short) 0, + (byte) adf1Aid.length ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 6: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList3, + (short) 0, + (short) baFileList3.length, + adf1Aid, + (short) 0, + (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 3, bRes); + break; + + /** Testcase 4 ***************************************** + * Register DF under ADF1 + *******************************************************/ + case 7: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList4, + (short) 0, + (short) baFileList4.length, + adf1Aid, + (short) 0, + (byte) adf1Aid.length ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 8: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList4, + (short) 0, + (short) baFileList4.length, + adf1Aid, + (short) 0, + (byte) adf1Aid.length ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 4, bRes); + break; + + + /** Testcase 5 ***************************************** + * NullPointerException Exception + *******************************************************/ + + case 9: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + null, + (short) 0, + (short) 0, + null, + (short) 0, + (byte) 0 ); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 5, bRes); + break; + + + /** Testcase 6 ***************************************** + * sOffset1 >= baFileList.length + *******************************************************/ + + case 10: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 8, + (short) 4, + null, + (short) 0, + (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 6, bRes); + break; + + /** Testcase 7 ***************************************** + * sOffset1 < 0 + *******************************************************/ + + case 11: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) -1, + (short) 4, + null, + (short) 0, + (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 7, bRes); + break; + + /** Testcase 8 ***************************************** + * sLength1 > baFileList.length + *******************************************************/ + + case 12: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) 10, + null, + (short) 0, + (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 8, bRes); + break; + + + /** Testcase 9 ***************************************** + * sOffset1 + sLength1 > baFileList.length + *******************************************************/ + + case 13: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 5, + (short) 4, + null, + (short) 0, + (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 9, bRes); + break; + + + /** Testcase 10 **************************************** + * sLength1 < 0 + *******************************************************/ + + case 14: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) -1, + null, + (short) 0, + (byte) 0 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 10, bRes); + break; + + + /** Testcase 11 ***************************************** + * sOffset2 >= baFileList.length + *******************************************************/ + + case 15: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) baFileList6.length, + baADFAid15, + (short) 15, + (byte) 6 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 11, bRes); + break; + + + /** Testcase 12 ***************************************** + * sOffset2 < 0 + *******************************************************/ + + case 16: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) baFileList6.length, + baADFAid15, + (short) -1, + (byte) 6 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 12, bRes); + break; + + + /** Testcase 13 ***************************************** + * sLength2 > baFileList.length + *******************************************************/ + + case 17: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) baFileList6.length, + baADFAid15, + (short) 0, + (byte) 16 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 13, bRes); + break; + + + /** Testcase 14 ***************************************** + * sOffset2 + sLength2 > baFileList.length + *******************************************************/ + + case 18: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) baFileList6.length, + baADFAid15, + (short) 10, + (byte) 6 ); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 14, bRes); + break; + + + /** Testcase 15 ***************************************** + * ILLEGAL_VALUE Exception + *******************************************************/ + + case 19: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) baFileList6.length, + baADFAid18, + (short) 0, + (byte) 4 ); + } + catch (SystemException e) { + bRes = (e.getReason() == SystemException.ILLEGAL_VALUE); + } + catch (Exception e) { + bRes = false; + } + + try { + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList6, + (short) 0, + (short) baFileList6.length, + baADFAid18, + (short) 0, + (byte) 18 ); + } + catch (SystemException e) { + bRes &= (e.getReason() == SystemException.ILLEGAL_VALUE); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome((byte) 15, bRes); + break; + + + /** Testcase 16 ***************************************** + * EVENT_MENU_SELECTION not allowed + *******************************************************/ + + case 20: + try { + bRes = false; + obReg.registerFileEvent(EVENT_MENU_SELECTION, + baFileList6, + (short) 0, + (short) baFileList6.length, + null, + (short) 0, + (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 16, bRes); + break; + + + /** Testcase 17 ***************************************** + * EVENT_MENU_SELECTION_HELP_REQUEST not allowed + *******************************************************/ + + case 21: + try { + bRes = false; + obReg.registerFileEvent(EVENT_MENU_SELECTION_HELP_REQUEST, + baFileList6, + (short) 0, + (short) baFileList6.length, + null, + (short) 0, + (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 17, bRes); + break; + + + /** Testcase 18 ***************************************** + * EVENT_TIMER_EXPIRATION not allowed + *******************************************************/ + + case 22: + try { + bRes = false; + obReg.registerFileEvent(EVENT_TIMER_EXPIRATION, + baFileList6, + (short) 0, + (short) baFileList6.length, + null, + (short) 0, + (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 18, bRes); + break; + + + /** Testcase 19 ***************************************** + * EVENT_STATUS_COMMAND not allowed + *******************************************************/ + + case 23: + try { + bRes = false; + obReg.registerFileEvent(EVENT_STATUS_COMMAND, + baFileList6, + (short) 0, + (short) baFileList6.length, + null, + (short) 0, + (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 19, bRes); + break; + + + /** Testcase 20 ***************************************** + * EVENT_NOT_SUPPORTED Exception + *******************************************************/ + + case 24: + try { + bRes = false; + obReg.registerFileEvent(EVENT_PROFILE_DOWNLOAD, + baFileList6, + (short) 0, + (short) baFileList6.length, + null, + (short) 0, + (byte) 0 ); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_SUPPORTED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome((byte) 20, bRes); + break; + + + /** Testcase 21 ***************************************** + * Register a deleted and recreated EF under MF + *******************************************************/ + + case 25: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList21, + (short) 0, + (short) baFileList21.length, + null, + (short) 0, + (byte) 0 ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 26: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList21, + (short) 0, + (short) baFileList21.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 21, bRes); + break; + + + /** Testcase 22 ***************************************** + * Register a deleted and recreated DF under MF + *******************************************************/ + + case 27: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList22, + (short) 0, + (short) baFileList22.length, + null, + (short) 0, + (byte) 0 ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 28: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList22, + (short) 0, + (short) baFileList22.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 22, bRes); + break; + + + /** Testcase 23 ***************************************** + * Register a non existant EF under MF + *******************************************************/ + + case 29: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList23, + (short) 0, + (short) baFileList23.length, + null, + (short) 0, + (byte) 0 ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 30: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList23, + (short) 0, + (short) baFileList23.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 23, bRes); + break; + + + + /** Testcase 24 ***************************************** + * Register a non existant DF under MF + *******************************************************/ + + case 31: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList24, + (short) 0, + (short) baFileList24.length, + null, + (short) 0, + (byte) 0 ); + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + } + catch (Exception e) { + bRes=false; + } + break; + + case 32: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, + baFileList24, + (short) 0, + (short) baFileList24.length, + null, + (short) 0, + (byte) 0 ); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 24, bRes); + break; + + } + } + + else if (event == EVENT_EXTERNAL_FILE_UPDATE) { + // If triggered on EVENT_EXTERNAL_FILE_UPDATE the applet stores the triggering File List in baFileList + sFileListLength = EnvelopeHandlerSystem.getTheHandler().findAndCopyValue(FILE_LIST_TAG, baFileList, (short)0); + hasBeenTriggered = true; + } + + else if (event == EVENT_CALL_CONTROL_BY_NAA) { + // If triggered on EVENT_CALL_CONTROL_BY_NAA the applet returns the latest triggering File List + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (hasBeenTriggered) { + envRespHdlr.appendArray(baFileList, (short) 0, (short) sFileListLength); + } + else { + envRespHdlr.appendTLV((byte)0x00, (byte)0x00); + } + + envRespHdlr.post(true); + + hasBeenTriggered = false; + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/Test_Api_2_Tkr_Rgfes_Bss_Bsb.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/Test_Api_2_Tkr_Rgfes_Bss_Bsb.java new file mode 100644 index 0000000000000000000000000000000000000000..fda43952a2b8c3e1630f5c8d3e98a9b4d5bf0606 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/Test_Api_2_Tkr_Rgfes_Bss_Bsb.java @@ -0,0 +1,353 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 2 + * Test source for ToolkitRegistry interface + * registerFileEvent() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rgfes_bss_bsb; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Rgfes_Bss_Bsb extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + + static final String MF = "3F00"; + static final String ADF = "7FFF"; + static final String DF_TEST = "7F4A"; + static final String DF_SUB_TEST = "5F10"; + static final String DF_NEW = "5F16"; + static final String EF_TAA = "4F10"; + static final String EF_TNEW = "4F16"; + static final String EF_TARU = "6F03"; + static final String EF_CARU = "6F09"; + static final String EF_LARU = "6F0C"; + + static final String fcp_EF_TARU = "8202 41218302 6F038A01 058B032F 06018002 0104"; + static final String fcp_EF_TAA = "8202 41218302 4F108A01 058B032F 06018001 03"; + static final String fcp_EF_TNEW = "8202 41218302 4F168A01 058B032F 06018001 03"; + + static final String fcp_DF_NEW = "8202 78218302 5F168A01 058B032F 06018102 0200C606 90018083 0101"; + static final String fcp_DF_SUB_TEST = "8202 78218302 5F108A01 058B032F 06018102 0200C606 90018083 0101"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Rgfes_Bss_Bsb() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00"); // LV ADF1 access domain DAP + + // test script + test.reset(); + response = test.terminalProfileSession("09030120"); + + + /** Testcase 1 & 2 ************************************* + * Register EF under MF + * Register DF under MF + *******************************************************/ + + for (int i=0; i < 2; i ++) { + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_CARU, true); + + if (i == 0) + result &= modifyEFandCheck(MF, EF_LARU, false); + else + result &= modifyEFandCheck(MF, EF_LARU, true); + + result &= modifyEFandCheck(MF, EF_TAA, false); + + test.unrecognizedEnvelope(); + } + + + + /** Testcase 3 & 4 ************************************* + * Register EF under ADF1 + * Register DF under ADF1 + *******************************************************/ + + for (int i=0; i < 2; i ++) { + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_CARU, true); + + if (i == 0) + result &= modifyEFandCheck(ADF, EF_LARU, false); + else + result &= modifyEFandCheck(ADF, EF_LARU, true); + + result &= modifyEFandCheck(ADF, EF_TAA, false); + + test.unrecognizedEnvelope(); + } + + /** Testcase 5 - 20 ********************************** + * 5. NullPointerException Exception + * 6. sOffset1 >= baFileList.length + * 7. sOffset1 < 0 + * 8. sLength1 > baFileList.length + * 9. sOffset1 + sLength1 > baFileList.length + * 10. sLength1 < 0 + * 11. sOffset2 >= baFileList.length + * 12. sOffset2 < 0 + * 13. sLength2 > baFileList.length + * 14. sOffset2 + sLength2 > baFileList.length + * 15. ILLEGAL_VALUE Exception + * 16. EVENT_MENU_SELECTION not allowed + * 17. EVENT_MENU_SELECTION_HELP_REQUEST not allowed + * 18. EVENT_TIMER_EXPIRATION not allowed + * 19. EVENT_STATUS_COMMAND not allowed + * 20. EVENT_NOT_SUPPORTED Exception + *****************************************************/ + + for (int i=5; i<=20; i++ ) { + test.unrecognizedEnvelope(); + } + + + /** Testcase 21 ************************************** + * Register a deleted and recreated EF under MF + *****************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + // delete EF_TARU + test.deleteFile(EF_TARU); + // create EF_TARU + test.createFile(fcp_EF_TARU); + + result &= modifyEFandCheck(MF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + + + /** Testcase 22 ************************************** + * Register a deleted and recreated DF under MF + *****************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TAA, true); + + // delete DF_SUB_TEST + test.selectFile(MF); + test.selectFile(DF_TEST); + test.deleteFile(DF_SUB_TEST); + + // create DF_SUB_TEST + test.createFile(fcp_DF_SUB_TEST); + + // create EF_TAA + test.selectFile(DF_SUB_TEST); + test.createFile(fcp_EF_TAA); + + result &= modifyEFandCheck(MF, EF_TAA, true); + + test.unrecognizedEnvelope(); + + + /** Testcase 23 ************************************** + * Register a non existant EF under MF + *****************************************************/ + + test.unrecognizedEnvelope(); + + // create MF/DF_TEST/DF_SUB_TEST/EF_TNEW + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(DF_SUB_TEST); + test.createFile(fcp_EF_TNEW); + + // update binary EF_TNEW + test.selectFile(EF_TNEW); + test.updateBinary("0000", "FFFFFF"); + result &= appletTriggered("01" + MF + DF_TEST + DF_SUB_TEST + EF_TNEW); + + test.unrecognizedEnvelope(); + + + /** Testcase 24 ************************************** + * Register a non existant DF under MF + *****************************************************/ + + test.unrecognizedEnvelope(); + + // create DF_NEW + test.selectFile(MF); + test.selectFile(DF_TEST); + test.createFile(fcp_DF_NEW); + + // create EF_TNEW + test.selectFile(DF_NEW); + test.createFile(fcp_EF_TNEW); + + // update binary EF_TNEW + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(DF_NEW); + test.selectFile(EF_TNEW); + test.updateBinary("0000", "FFFFFF"); + result &= appletTriggered("01" + MF + DF_TEST + DF_NEW + EF_TNEW); + + test.unrecognizedEnvelope(); + + // delete DF_NEW + test.selectFile(MF); + test.selectFile(DF_TEST); + test.deleteFile(DF_NEW); + + + /***************************************************** + * Restore modified files + *****************************************************/ + + // restore EF_CARU under ADF + test.selectApplication(AID_ADF_1); + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + // restore EF_CARU under MF + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + // restore EF_TAA under MF + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(DF_SUB_TEST); + test.selectFile(EF_TAA); + test.updateBinary("0000", "AAAAAA"); + + // restore EF_TARU under MF + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_TARU); + String FFx130 = ""; + for (int i=0; i<130; i++) + FFx130 += "FF"; + test.updateBinary("0000", FFx130); + test.updateBinary("0082", FFx130); + + + /***************************************************** + * Finish test + *****************************************************/ + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "18CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } + + + /** + * Check the File List which caused the latest EXTERNAL_FILE_UDPATE + * and compare it whith the File List given in parameter. + * If the applet has not been triggered it will return "000100" + */ + + private boolean appletTriggered(String data) { + response = test.envelopeCallControlByNAA(); + return response.checkData(data); + } + + + /** + * Perform an action on the specified EF in order to test + * if the test applet is triggered with an EXTERNAL_FILE_UDPATE event. + */ + + private boolean modifyEFandCheck(String mfadf, String fid, boolean shouldTrigger) { + + // select correct file + if (mfadf == ADF) test.selectApplication(AID_ADF_1); + test.selectFile(mfadf); + test.selectFile(DF_TEST); + if (fid == EF_TAA) test.selectFile(DF_SUB_TEST); + test.selectFile(fid); + + // modify the EF + if (fid == EF_CARU) test.increase("000001"); + else if (fid == EF_LARU) test.updateRecord("01","04","55555555"); + else test.updateBinary("0000", "FFFFFF"); + + // create the string to pass to appletTriggered() + String checkString = ("01" + MF); + if (mfadf == ADF) checkString += ADF; + + if (!shouldTrigger) checkString = "000100"; + else if (fid == EF_TARU) checkString += (DF_TEST + EF_TARU); + else if (fid == EF_CARU) checkString += (DF_TEST + EF_CARU); + else if (fid == EF_LARU) checkString += (DF_TEST + EF_LARU); + else if (fid == EF_TAA) checkString += (DF_TEST + DF_SUB_TEST + EF_TAA); + + // return the result of the triggering + return appletTriggered(checkString); + } + + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..142ce223f340900153b7293cd06863ef5a520803 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_rgfes_bss_bsb.Api_2_Tkr_Rgfes_Bss_Bsb_1 +uicc.test.toolkit.api_2_tkr_rgfes_bss_bsb +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/javacard/api_2_tkr_rgfes_bss_bsb.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/javacard/api_2_tkr_rgfes_bss_bsb.cap new file mode 100644 index 0000000000000000000000000000000000000000..d3604434836881a75bb3859288e8b871bff95a5b Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfes_bss_bsb/javacard/api_2_tkr_rgfes_bss_bsb.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/Api_2_Tkr_Rgfeso_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/Api_2_Tkr_Rgfeso_1.java new file mode 100644 index 0000000000000000000000000000000000000000..87b2722ddc3b24e67c4d67165e769e74b073356c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/Api_2_Tkr_Rgfeso_1.java @@ -0,0 +1,387 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rgfeso; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import uicc.access.*; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, registerFileEvent() method + * applet 1 + */ +public class Api_2_Tkr_Rgfeso_1 extends TestToolkitApplet { + + private boolean bRes = true; + private byte callNb = 1; + + private boolean hasBeenTriggered = false; + private byte[] adf1Aid = null; + private FileView uiccFileView = null; + private FileView adf1FileView = null; + + private short sFileListLength = 0; + private byte[] baFileList = null; + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Rgfeso_1() { + baFileList = new byte[16]; + adf1Aid = new byte[16]; + UICCTestConstants uiccTestConstants = new UICCTestConstants(); + Util.arrayCopyNonAtomic(uiccTestConstants.AID_ADF1,(short)0,adf1Aid,(short)0,(short)adf1Aid.length); + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Rgfeso_1 thisApplet = new Api_2_Tkr_Rgfeso_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialize the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + // Register to EVENT_CALL_CONTROL_BY_NAA + thisApplet.obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + switch (callNb++) { + + /** Testcase 1 ***************************************** + * Register EF under MF + *******************************************************/ + + case 1: + try { + bRes = !obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + uiccFileView = UICCSystem.getTheUICCView(JCSystem.CLEAR_ON_RESET); + uiccFileView.select(UICCTestConstants.FID_MF); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + uiccFileView.select(UICCTestConstants.FID_EF_TARU); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 2: + try { + bRes &= obReg.isEventSet(EVENT_EXTERNAL_FILE_UPDATE); + + uiccFileView.select(UICCTestConstants.FID_EF_CARU); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 3: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + + uiccFileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 1, bRes); + break; + + + /** Testcase 2 ***************************************** + * Register DF under MF + *******************************************************/ + + case 4: + try { + bRes = true; + uiccFileView.select(UICCTestConstants.FID_MF); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 5: + try { + uiccFileView.select(UICCTestConstants.FID_MF); + uiccFileView.select(UICCTestConstants.FID_DF_TEST); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, uiccFileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 2, bRes); + break; + + /** Testcase 3 ***************************************** + * Register EF under ADF1 + *******************************************************/ + + case 6: + try { + bRes = true; + adf1FileView = UICCSystem.getTheFileView(adf1Aid, (short) 0, (byte) adf1Aid.length, JCSystem.NOT_A_TRANSIENT_OBJECT); + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + adf1FileView.select(UICCTestConstants.FID_EF_TARU); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 7: + try { + adf1FileView.select(UICCTestConstants.FID_EF_CARU); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 8: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + adf1FileView.select(UICCTestConstants.FID_EF_TARU); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 3, bRes); + break; + + /** Testcase 4 ***************************************** + * Register DF under ADF1 + *******************************************************/ + + case 9: + try { + bRes = true; + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 10: + try { + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 4, bRes); + break; + + + /** Testcase 5 ***************************************** + * NullPointerException Exception + *******************************************************/ + + case 11: + try { + bRes = false; + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, null); + } + catch (NullPointerException e) { + bRes = true; + } + catch (Exception e) {} + + reportTestOutcome((byte) 5, bRes); + + + /** Testcase 6 ***************************************** + * EVENT_MENU_SELECTION not allowed + *******************************************************/ + + try { + bRes = false; + obReg.registerFileEvent(EVENT_MENU_SELECTION, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 6, bRes); + + /** Testcase 7 ***************************************** + * EVENT_MENU_SELECTION_HELP_REQUEST not allowed + *******************************************************/ + + try { + bRes = false; + obReg.registerFileEvent(EVENT_MENU_SELECTION_HELP_REQUEST, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 7, bRes); + + /** Testcase 8 ***************************************** + * EVENT_TIMER_EXPIRATION not allowed + *******************************************************/ + + try { + bRes = false; + obReg.registerFileEvent(EVENT_TIMER_EXPIRATION, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 8, bRes); + + + /** Testcase 9 ***************************************** + * EVENT_STATUS_COMMAND not allowed + *******************************************************/ + + try { + bRes = false; + obReg.registerFileEvent(EVENT_STATUS_COMMAND, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 9, bRes); + + + /** Testcase 10 ***************************************** + * EVENT_NOT_SUPPORTED Exception + *******************************************************/ + + try { + bRes = false; + obReg.registerFileEvent(EVENT_PROFILE_DOWNLOAD, uiccFileView); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_SUPPORTED); + } + catch (Exception e) {} + + reportTestOutcome((byte) 10, bRes); + + + /** Testcase 11 ***************************************** + * Register a deleted and recreated EF under ADF + *******************************************************/ + + case 12: + try { + bRes = true; + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + adf1FileView.select(UICCTestConstants.FID_EF_TARU); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 13: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 11, bRes); + break; + + + /** Testcase 12 ***************************************** + * Register a deleted and recreated DF under ADF + *******************************************************/ + + case 14: + try { + bRes = true; + adf1FileView.select(UICCTestConstants.FID_ADF); + adf1FileView.select(UICCTestConstants.FID_DF_TEST); + adf1FileView.select(UICCTestConstants.FID_DF_SUB_TEST); + obReg.registerFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + break; + + case 15: + try { + obReg.deregisterFileEvent(EVENT_EXTERNAL_FILE_UPDATE, adf1FileView); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome((byte) 12, bRes); + break; + + } + } + + else if (event == EVENT_EXTERNAL_FILE_UPDATE) { + sFileListLength = EnvelopeHandlerSystem.getTheHandler().findAndCopyValue((byte)0x92, baFileList, (short)0); + hasBeenTriggered = true; + } + + else if (event == EVENT_CALL_CONTROL_BY_NAA) { + EnvelopeResponseHandler envRespHdlr = EnvelopeResponseHandlerSystem.getTheHandler(); + + if (hasBeenTriggered) { + envRespHdlr.appendArray(baFileList, (short) 0, (short) sFileListLength); + } + else { + envRespHdlr.appendTLV((byte)0x00, (byte)0x00); + } + + envRespHdlr.post(true); + + hasBeenTriggered = false; + } + + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/Test_Api_2_Tkr_Rgfeso.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/Test_Api_2_Tkr_Rgfeso.java new file mode 100644 index 0000000000000000000000000000000000000000..27d793412b710a47b115e7654ac48dc69208fbc4 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/Test_Api_2_Tkr_Rgfeso.java @@ -0,0 +1,302 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 2 + * Test source for ToolkitRegistry interface + * registerFileEvent() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rgfeso; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Rgfeso extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_rgfeso"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + static final String AID_ADF_1 = "A0000000 090005FF FFFFFF89 E0000002"; + + static final String MF = "3F00"; + static final String ADF = "7FFF"; + static final String DF_TEST = "7F4A"; + static final String DF_SUB_TEST = "5F10"; + static final String EF_TAA = "4F10"; + static final String EF_TARU = "6F03"; + static final String EF_CARU = "6F09"; + static final String EF_LARU = "6F0C"; + + static final String fcp_EF_TARU = "8202 41218302 6F038A01 058B036F 06018002 0104"; + static final String fcp_EF_TAA = "8202 41218302 4F108A01 058B036F 06018001 03"; + static final String fcp_DF_SUB_TEST = "8202 78218302 5F108A01 058B036F 06018102 0200C606 90018083 0101"; + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Rgfeso() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0A" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00" + // V Maximum number of services + "8118" + // TLV UICC Access Application specific parameters + "00" + // LV UICC file system AID + "0100" + // LV UICC file system access aomain + "00" + // LV UICC file system access domain DAP + "10A0000000090005FFFFFFFF89E0000002" + // LV ADF1 AID + "0100" + // LV ADF1 access domain + "00"); // LV ADF1 access domain DAP + + // test script + test.reset(); + response = test.terminalProfileSession("09030120"); + + + /** Testcase 1 ***************************************** + * Register EF under MF + *******************************************************/ + + test.unrecognizedEnvelope(); + + // update binary EF_TARU and check that applet is correctly triggered + result &= modifyEFandCheck(MF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_CARU, true); + result &= modifyEFandCheck(MF, EF_LARU, false); + result &= modifyEFandCheck(MF, EF_TAA, false); + + test.unrecognizedEnvelope(); + + + /** Testcase 2 ***************************************** + * Register DF under MF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(MF, EF_TARU, true); + result &= modifyEFandCheck(MF, EF_CARU, true); + result &= modifyEFandCheck(MF, EF_LARU, true); + result &= modifyEFandCheck(MF, EF_TAA, false); + + test.unrecognizedEnvelope(); + + + /** Testcase 3 ***************************************** + * Register EF under ADF1 + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_CARU, true); + result &= modifyEFandCheck(ADF, EF_LARU, false); + result &= modifyEFandCheck(ADF, EF_TAA, false); + + test.unrecognizedEnvelope(); + + /** Testcase 4 ***************************************** + * Register DF under ADF1 + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + result &= modifyEFandCheck(ADF, EF_CARU, true); + result &= modifyEFandCheck(ADF, EF_LARU, true); + result &= modifyEFandCheck(ADF, EF_TAA, false); + + test.unrecognizedEnvelope(); + + /** Testcase 5 - 10 ********************************** + * 5. NullPointerException Exception + * 6. EVENT_MENU_SELECTION not allowed + * 7. EVENT_MENU_SELECTION_HELP_REQUEST not allowed + * 8. EVENT_TIMER_EXPIRATION not allowed + * 9. EVENT_STATUS_COMMAND not allowed + * 10. EVENT_NOT_SUPPORTED Exception + *****************************************************/ + + test.unrecognizedEnvelope(); + + + /** Testcase 11 **************************************** + * Register a deleted and recreated EF under ADF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + // delete EF_TARU + test.deleteFile(EF_TARU); + // create EF_TARU + test.createFile(fcp_EF_TARU); + + result &= modifyEFandCheck(ADF, EF_TARU, true); + + test.unrecognizedEnvelope(); + + + /** Testcase 12 **************************************** + * Register a deleted and recreated DF under ADF + *******************************************************/ + + test.unrecognizedEnvelope(); + + result &= modifyEFandCheck(ADF, EF_TAA, true); + + // delete DF_SUB_TEST + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.deleteFile(DF_SUB_TEST); + + // create DF_SUB_TEST + test.createFile(fcp_DF_SUB_TEST); + test.selectFile(DF_SUB_TEST); + + // create EF_TAA + test.createFile(fcp_EF_TAA); + + result &= modifyEFandCheck(ADF, EF_TAA, true); + + test.unrecognizedEnvelope(); + + + + /***************************************************** + * Restore modified files + *****************************************************/ + + // restore EF_CARU under MF + test.selectFile(MF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + // restore EF_CARU under ADF + test.selectApplication(AID_ADF_1); + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.selectFile(EF_CARU); + test.updateRecord("00", "03", "AAAAAA"); + test.updateRecord("00", "03", "555555"); + + // restore EF_TAA under ADF + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.selectFile(DF_SUB_TEST); + test.selectFile(EF_TAA); + test.updateBinary("0000", "AAAAAA"); + + // restore EF_TARU under ADF + test.selectFile(ADF); + test.selectFile(DF_TEST); + test.selectFile(EF_TARU); + String FFx130 = ""; + for (int i=0; i<=130; i++) + FFx130 += "FF"; + test.updateBinary("0000", FFx130); + test.updateBinary("0082", FFx130); + + + + /***************************************************** + * Finish test + *****************************************************/ + + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "0CCCCCCC CCCCCCCC CCCCCCCC CC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } + + + /** + * Check the File List which caused the latest EXTERNAL_FILE_UDPATE + * and compare it whith the File List given in parameter. + * If the applet has not been triggered it will return "000100" + */ + + private boolean appletTriggered(String data) { + response = test.envelopeCallControlByNAA(); + return response.checkData(data); + } + + /** + * Perform an action on the specified EF in order to test + * if the test applet is triggered with an EXTERNAL_FILE_UDPATE event. + */ + + private boolean modifyEFandCheck(String mfadf, String fid, boolean shouldTrigger) { + + // select correct file + if (mfadf == ADF) test.selectApplication(AID_ADF_1); + test.selectFile(mfadf); + test.selectFile(DF_TEST); + if (fid == EF_TAA) test.selectFile(DF_SUB_TEST); + test.selectFile(fid); + + // modify the EF + if (fid == EF_CARU) test.increase("000001"); + else if (fid == EF_LARU) test.updateRecord("01","04","55555555"); + else test.updateBinary("0000", "FFFFFF"); + + // create the string to pass to appletTriggered() + String checkString = "01" + MF; + if (mfadf == ADF) checkString += ADF; + + if (!shouldTrigger) checkString = "000100"; + else if (fid == EF_TARU) checkString += (DF_TEST + EF_TARU); + else if (fid == EF_CARU) checkString += (DF_TEST + EF_CARU); + else if (fid == EF_LARU) checkString += (DF_TEST + EF_LARU); + else if (fid == EF_TAA) checkString += (DF_TEST + DF_SUB_TEST + EF_TAA); + + // return the result of the triggering + return appletTriggered(checkString); + } + +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..d77a1fe0e8dc88954a8dfd2e8dda7b2a938fa9b9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_rgfeso.Api_2_Tkr_Rgfeso_1 +uicc.test.toolkit.api_2_tkr_rgfeso +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/javacard/api_2_tkr_rgfeso.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/javacard/api_2_tkr_rgfeso.cap new file mode 100644 index 0000000000000000000000000000000000000000..fa7ce6effcc18757f10841ed27dadeea4aecc922 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rgfeso/javacard/api_2_tkr_rgfeso.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/Api_2_Tkr_Rpol_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/Api_2_Tkr_Rpol_1.java new file mode 100644 index 0000000000000000000000000000000000000000..8feb33544f2721ac2399603000bcf910823a785c --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/Api_2_Tkr_Rpol_1.java @@ -0,0 +1,198 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rpol; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, requestPollInterval() method + * applet 1 + */ +public class Api_2_Tkr_Rpol_1 extends TestToolkitApplet { + + private short CallNB = 0; + private short [] AllowedDurationValues = {(short) 1, (short) 255, (short) 256, (short) 15300}; + private short [] ForbiddenDurationValues = {(short) 15301, (short) 32767, (short) -2, (short)-32768 }; + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Rpol_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Rpol_1 thisApplet = new Api_2_Tkr_Rpol_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes ; + byte testCaseNb = (byte) 7; + short i; + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + CallNB++; + switch (CallNB) { + + case (short)1: + // ----------------------------------------------------------------- + // Test Case 1: Request a value between 1 and 15300 s + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + + bRes = !obReg.isEventSet(EVENT_STATUS_COMMAND); + if (bRes) { + for (i = 0;bRes && (i < AllowedDurationValues.length);i++) { + try { + bRes = false; + obReg.requestPollInterval(AllowedDurationValues[i]); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + } + } + bRes = bRes && obReg.isEventSet(EVENT_STATUS_COMMAND); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2 : Check Applet is triggered by a STATUS command + // ----------------------------------------------------------------- + reportTestOutcome((byte)2, false); + break; + + case (short)2: + // ----------------------------------------------------------------- + // Test Case 3 : Requesting POLL SYSTEM DURATION + // ----------------------------------------------------------------- + testCaseNb = (byte) 3; + + bRes = obReg.isEventSet(EVENT_STATUS_COMMAND); + if (bRes) { + bRes = false; + try { + obReg.requestPollInterval(POLL_SYSTEM_DURATION); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + } + bRes = bRes && obReg.isEventSet(EVENT_STATUS_COMMAND); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4 : Check Applet is triggered by a STATUS command + // ----------------------------------------------------------------- + reportTestOutcome((byte)4, false); + break; + + case (short)3: + // ----------------------------------------------------------------- + // Test Case 5 : requestPollInterval(duration) for following + // values: 15301, 32767, -2, -32768 + // ----------------------------------------------------------------- + testCaseNb = (byte)5; + bRes = true; + + for (i = (short) 0;bRes && (i < ForbiddenDurationValues.length);i++) { + + bRes = false; + try { + obReg.requestPollInterval(ForbiddenDurationValues[i]); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.REGISTRY_ERROR); + } + catch (Exception e) { + bRes = false; + } + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6: Requesting POLL_NO_DURATION + // ----------------------------------------------------------------- + testCaseNb = (byte)6; + bRes = obReg.isEventSet(EVENT_STATUS_COMMAND); + + if (bRes) { + bRes = false; + try { + obReg.requestPollInterval(POLL_NO_DURATION); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + } + bRes = bRes && !obReg.isEventSet(EVENT_STATUS_COMMAND); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7: Check Applet isn't triggered by a STATUS command + // ----------------------------------------------------------------- + reportTestOutcome((byte) 7, true); + + } // End switch + } + else { + if (event == EVENT_STATUS_COMMAND) { + + switch (CallNB) { + + case (short)1: + // ----------------------------------------------------------------- + // Test Case 2: Check Applet is triggered by a STATUS command + // ----------------------------------------------------------------- + reportTestOutcome((byte) 2, true); + break; + + case (short)2: + // ----------------------------------------------------------------- + // Test Case 4: Check Applet is triggered by a STATUS command + // ----------------------------------------------------------------- + + reportTestOutcome((byte) 4, true); + break; + + case (short)3: + // ----------------------------------------------------------------- + // Test Case 7 : Check Applet isn't triggered by an STATUS command + // ----------------------------------------------------------------- + reportTestOutcome((byte) 7, false); + } + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/Test_Api_2_Tkr_Rpol.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/Test_Api_2_Tkr_Rpol.java new file mode 100644 index 0000000000000000000000000000000000000000..5269606fe3233c58ad6828c93e3417f7c2972dd9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/Test_Api_2_Tkr_Rpol.java @@ -0,0 +1,96 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * requestPollInterval() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rpol; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Rpol extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_rpol"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Rpol() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("0101"); + + // test case 1 + test.unrecognizedEnvelope(); + + // test case 2 + test.reset(); + test.terminalProfileSession("0001"); + response = test.status("00", "00", "01"); + result = response.checkSw("9000"); + + // test case 3 + test.unrecognizedEnvelope(); + + // test case 4 + test.reset(); + test.terminalProfileSession("0001"); + response = test.status("00", "00", "01"); + result &= response.checkSw("9000"); + + // test case 5, 6 + test.unrecognizedEnvelope(); + + // test case 7 + test.reset(); + test.terminalProfileSession("0001"); + response = test.status("00", "00", "01"); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..494c601b9a4657d43b166273b47c906fbbd2f854 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_rpol.Api_2_Tkr_Rpol_1 +uicc.test.toolkit.api_2_tkr_rpol +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/javacard/api_2_tkr_rpol.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/javacard/api_2_tkr_rpol.cap new file mode 100644 index 0000000000000000000000000000000000000000..0d9018b40604e0da4cdb62dbaf9a1a80f72661c3 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rpol/javacard/api_2_tkr_rpol.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Api_2_Tkr_Rsid_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Api_2_Tkr_Rsid_1.java new file mode 100644 index 0000000000000000000000000000000000000000..503325f267e99f006cc6e0538939eb3e9ded9a4e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Api_2_Tkr_Rsid_1.java @@ -0,0 +1,199 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rsid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, releaseServiceIdentifier() method + * applet 1 + */ +public class Api_2_Tkr_Rsid_1 extends TestToolkitApplet { + + boolean bRes; + byte testCaseNb = (byte)0x00; + + // Service ID value range + private static byte MIN_SERVICE_ID = 0; + private static byte MAX_SERVICE_ID = 7; + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'1'}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Rsid_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Rsid_1 thisApplet = new Api_2_Tkr_Rsid_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, (byte) 0, + false, (byte) 0, (short) 0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + if (event == EVENT_MENU_SELECTION) { + + switch (testCaseNb) { + case (byte)0x00: + // Test Case 1: Release not allocated services + testCaseNb = (byte)0x01; + bRes = true; + + for (byte i = (byte)0x80; (i < (byte)0x7F) && (bRes); i++) { + try { + obReg.releaseServiceIdentifier((byte)i); + bRes = false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.INVALID_SERVICE_ID); + } + catch (Exception e) { + bRes = false; + } + } + reportTestOutcome(testCaseNb, bRes); + + // Test Case 2: Release allocated services + testCaseNb = (byte)0x02; + try { + // allocate 8 service id. + for (byte i = MIN_SERVICE_ID; i < (MAX_SERVICE_ID + 1); i++) { + obReg.allocateServiceIdentifier(); + } + + // release 7 service id. + for (byte i = MIN_SERVICE_ID; i < MAX_SERVICE_ID; i++) { + obReg.releaseServiceIdentifier(i); + } + + // check applet is registered to EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + bRes = obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + + // Test Case 3: Release invalid service ID + testCaseNb = (byte)0x03; + try { + obReg.releaseServiceIdentifier((byte)0xFF); + bRes = false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.INVALID_SERVICE_ID); + } + catch (Exception e) { + bRes = false; + } + // check applet is still registered to EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + bRes = bRes && obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + + reportTestOutcome(testCaseNb, bRes); + + // Test Case 4: Release last service + testCaseNb = (byte)0x04; + try { + obReg.releaseServiceIdentifier((byte)7); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + // check applet is not registered to EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + bRes = bRes && !obReg.isEventSet(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION); + + reportTestOutcome(testCaseNb, bRes); + + // Test Case 5: Released services can be allocated + testCaseNb = (byte)0x05; + try { + for (byte i = MIN_SERVICE_ID; i < (MAX_SERVICE_ID + 1); i++) { + obReg.allocateServiceIdentifier(); + } + obReg.releaseServiceIdentifier((byte)0x01); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + case (byte)0x05: + // Test Case 6: Release all services for this applet + testCaseNb = (byte)0x06; + try { + obReg.releaseServiceIdentifier((byte)0x00); + for (byte i = 2; i < (MAX_SERVICE_ID + 1); i++) { + obReg.releaseServiceIdentifier(i); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // Test Case 7: Check Applet1 is not triggered by envelope(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) command + testCaseNb = (byte)0x07; + reportTestOutcome(testCaseNb, true); + break; + + case (byte)0x07: + // Test Case 8: Release invalid service ID + testCaseNb = (byte)0x08; + bRes = true; + + try { + for (byte i = MIN_SERVICE_ID; (i < MAX_SERVICE_ID) && bRes; i++) { + bRes = bRes && !(obReg.allocateServiceIdentifier() == (byte)0x01); + } + obReg.releaseServiceIdentifier((byte)0x01); + bRes = false; + } + catch (ToolkitException e) { + bRes = bRes && (e.getReason() == ToolkitException.INVALID_SERVICE_ID); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } + } + + if (event == EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) { + // Test Case 7: Check Applet1 is not triggered by envelope(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) command + testCaseNb = 0x07; + bRes = false; + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Api_2_Tkr_Rsid_2.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Api_2_Tkr_Rsid_2.java new file mode 100644 index 0000000000000000000000000000000000000000..13e20d7cd46ae30727f5da12b13cd5bd098b84ac --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Api_2_Tkr_Rsid_2.java @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rsid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, releaseServiceIdentifier() method + * applet 2 + */ +public class Api_2_Tkr_Rsid_2 extends TestToolkitApplet { + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'2'}; + private byte[] abServiceRecord = {(byte)0x00, (byte)0x01, (byte)0x00}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Rsid_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Rsid_2 thisApplet = new Api_2_Tkr_Rsid_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, (byte) 0, + false, (byte) 0, (short) 0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes; + byte testCaseNb; + + if (event == EVENT_MENU_SELECTION) { + // Test Case 5: Released services can be allocated + testCaseNb = (byte)0x01; + + try { + bRes = (obReg.allocateServiceIdentifier() == (byte)0x01); + // Get the system instance of handlers + ProactiveHandler proHdlr = ProactiveHandlerSystem.getTheHandler() ; + // Send SERVICE ADD + proHdlr.init(PRO_CMD_DECLARE_SERVICE, (byte)0x00 /*Add*/, (byte)DEV_ID_TERMINAL); + proHdlr.appendTLV(TAG_SERVICE_RECORD, abServiceRecord, (short)0x00, (short)abServiceRecord.length); + proHdlr.send(); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + } + + // Test Case 7: check this applet is triggered by envelope(EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) command + if (event == EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION) { + testCaseNb = (byte)0x02; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Test_Api_2_Tkr_Rsid.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Test_Api_2_Tkr_Rsid.java new file mode 100644 index 0000000000000000000000000000000000000000..43b1719accc3c83748050b4bcd62f9b7cfef2264 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/Test_Api_2_Tkr_Rsid.java @@ -0,0 +1,111 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * releaseServiceIdentifier() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rsid; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Rsid extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_rsid"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 20020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 20020102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Rsid() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "08"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0102" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "01"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010000 0040"); + + // test case 1 to 5: trigger Applet1 with EVENT_MENU_SELECTION (item = '01') + response = test.envelopeMenuSelection("900101",""); + result = response.checkSw("9000"); + + // test case 5: trigger Applet2 with EVENT_MENU_SELECTION (item = '02') + response = test.envelopeMenuSelection("900102",""); + result &= response.checkSw("9110"); + response = test.fetch("10"); + response = test.terminalResponse("81030147 00820282 81830100"); + + + // test case 6: trigger Applet1 with EVENT_MENU_SELECTION (item = '01') + response = test.envelopeMenuSelection("900101",""); + result &= response.checkSw("9000"); + + // test case 7: trigger Applet1 with EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + response = test.envelopeEventDownloadLocalConnection("4103000100"); + result &= response.checkSw("9000"); + + // test case 8: trigger Applet1 with EVENT_MENU_SELECTION (item = '01') + response = test.envelopeMenuSelection("900101",""); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "08CCCCCC CCCCCCCC CC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "02CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ef5e89d6c85167b4424010a3dba36a711aed16bb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x02:0x00:0x01 uicc.test.toolkit.api_2_tkr_rsid.Api_2_Tkr_Rsid_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_rsid.Api_2_Tkr_Rsid_1 +uicc.test.toolkit.api_2_tkr_rsid +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/javacard/api_2_tkr_rsid.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/javacard/api_2_tkr_rsid.cap new file mode 100644 index 0000000000000000000000000000000000000000..bfe2037ddc0257f798de148cfa4547dbb1644b0f Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rsid/javacard/api_2_tkr_rsid.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/Api_2_Tkr_Rtim_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/Api_2_Tkr_Rtim_1.java new file mode 100644 index 0000000000000000000000000000000000000000..7767b481c4980b00b089f18f4a514bc6c220c363 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/Api_2_Tkr_Rtim_1.java @@ -0,0 +1,214 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rtim; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, releaseTimer() method + * applet 1 + */ +public class Api_2_Tkr_Rtim_1 extends TestToolkitApplet { + + // Timer ID value range + private static short MIN_TIMER_ID = 1; + private static short MAX_TIMER_ID = 8; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Rtim_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) + { + // Create a new applet instance + Api_2_Tkr_Rtim_1 thisApplet = new Api_2_Tkr_Rtim_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes ; + byte testCaseNb; + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + // ----------------------------------------------------------------- + // Test Case 1: Release not allocated timers + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = false; + + try { + obReg.releaseTimer((byte)0); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.INVALID_TIMER_ID); + } + catch (Exception e) { + bRes = false; + } + + try { + for (short i = ((short)1); (i < ((short)256)) && (bRes);i++) { + bRes = false; + obReg.releaseTimer((byte)i); + } + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.INVALID_TIMER_ID); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 2: Release allocated timers + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + try { + for (short i = MIN_TIMER_ID; (i < (short) (MAX_TIMER_ID + 1)); i++){ + obReg.allocateTimer(); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + try { + obReg.releaseTimer((byte)MIN_TIMER_ID); + bRes = bRes && obReg.isEventSet(EVENT_TIMER_EXPIRATION); + } + catch (Exception e) { + bRes = false; + } + + try { + for (short i = (short)(MIN_TIMER_ID + 1); + (i < MAX_TIMER_ID ) && (bRes);i++) { + obReg.releaseTimer((byte) i); + + bRes = obReg.isEventSet(EVENT_TIMER_EXPIRATION); + } + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3: Release invalid timer ID + // ----------------------------------------------------------------- + + testCaseNb = (byte)3; + bRes = false; + + try { + obReg.releaseTimer((byte)255); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.INVALID_TIMER_ID); + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && obReg.isEventSet(EVENT_TIMER_EXPIRATION); + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4: Release last timer + // ----------------------------------------------------------------- + testCaseNb = (byte)4; + bRes = false; + + try { + obReg.releaseTimer((byte)MAX_TIMER_ID); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + bRes = bRes && !obReg.isEventSet(EVENT_TIMER_EXPIRATION); + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 5: Check we can allocate timers + // ----------------------------------------------------------------- + testCaseNb = (byte)5; + bRes = false; + + try { + for (short i = MIN_TIMER_ID; (i < (short)(MAX_TIMER_ID + 1));i++) { + obReg.allocateTimer(); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6: Release all timers + // ----------------------------------------------------------------- + testCaseNb = (byte)6; + bRes = false; + + try { + for (short i = MIN_TIMER_ID; (i < (short)(MAX_TIMER_ID+1));i++) { + obReg.releaseTimer((byte)i); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7: Initialiation of the test case + // ----------------------------------------------------------------- + testCaseNb = (byte)7; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + else { + if (event == EVENT_TIMER_EXPIRATION) { + + // ----------------------------------------------------------------- + // Test Case 7: Check applet is not triggered + // by ENVELOPE(TIMER_EXPIRATION) command any more + // ----------------------------------------------------------------- + testCaseNb = (byte)7; + reportTestOutcome(testCaseNb, false); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/Test_Api_2_Tkr_Rtim.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/Test_Api_2_Tkr_Rtim.java new file mode 100644 index 0000000000000000000000000000000000000000..d455037046cb65abd6ee0f128d51335fce2a6555 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/Test_Api_2_Tkr_Rtim.java @@ -0,0 +1,97 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * releaseTimer() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_rtim; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Rtim extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_rtim"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Rtim() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "08" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("2101"); + + // test case 1 to 6 + response = test.unrecognizedEnvelope(); + result = response.checkSw("9000"); + + // test case 7 + response = test.envelopeTimerExpiration("240101"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240102"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240103"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240104"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240105"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240106"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240107"); + result &= response.checkSw("9000"); + + response = test.envelopeTimerExpiration("240108"); + result &= response.checkSw("9000"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "07CCCCCC CCCCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..acee246b386efeb3acdbf7f14bd3e478e0b78f77 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_rtim.Api_2_Tkr_Rtim_1 +uicc.test.toolkit.api_2_tkr_rtim +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/javacard/api_2_tkr_rtim.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/javacard/api_2_tkr_rtim.cap new file mode 100644 index 0000000000000000000000000000000000000000..cbeba42601ba2f193ee4ef4f93dea4950680e013 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_rtim/javacard/api_2_tkr_rtim.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Api_2_Tkr_Sevl_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Api_2_Tkr_Sevl_1.java new file mode 100644 index 0000000000000000000000000000000000000000..52b84a2c9d9fa5fb7df52bf66e9fa94d82962671 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Api_2_Tkr_Sevl_1.java @@ -0,0 +1,493 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevl; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setEventList() method + * applet 1 + */ +public class Api_2_Tkr_Sevl_1 extends TestToolkitApplet { + + // Not allowed events for the setEvent() method + private static short[] NOT_ALLOWED_SET_EVENTS = {EVENT_MENU_SELECTION, EVENT_MENU_SELECTION_HELP_REQUEST, + EVENT_TIMER_EXPIRATION,EVENT_STATUS_COMMAND, + EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION, EVENT_EXTERNAL_FILE_UPDATE}; + + // Not supported events for the setEvent() method + private static short NOT_SUPPORTED_SETEVENT_10 = 10; + private static short NOT_SUPPORTED_SETEVENT_24 = 24; + + // Event value range + private static short MIN_EVENT_NB = 7; + private static short MAX_EVENT_NB = 29; + + // Events allowed and supported + private static short OFFSET = 5; + private static short MAX_EVENT = 21; // 27 events - 6 not allowed events + private short[] EventList = new short[MAX_EVENT]; + + // Event allocated only for 1 applet + private short[] List = {EVENT_CALL_CONTROL_BY_NAA}; + + private static byte[] MenuEntry = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', + (byte)'e', (byte)'t', (byte)'1'}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Sevl_1() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Api_2_Tkr_Sevl_1 thisApplet = new Api_2_Tkr_Sevl_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuEntry, (short)0, (short)MenuEntry.length, (byte)0, + false, (byte)0, (short)0); + } + + /** + * Method called by the processToolkit() method to know if event + * is an allowed event for the clearEvent() or setEvent() method + */ + private boolean isEventAllowed(short event) { + boolean allowed = true; + + for(short i = 0; (i < NOT_ALLOWED_SET_EVENTS.length) && (allowed); i++) { + allowed = (NOT_ALLOWED_SET_EVENTS[i] != event); + } + return allowed; + } + + /** + * Method called by the processToolkit() method to know if event + * is a supported event for the setEvent() method + */ + private boolean isEventSupported(short event) { + return (((event != NOT_SUPPORTED_SETEVENT_10) + &&(event != NOT_SUPPORTED_SETEVENT_24) + && (event >= MIN_EVENT_NB) + && (event <= MAX_EVENT_NB)) + || (event == EVENT_UNRECOGNIZED_ENVELOPE) + || (event == EVENT_PROFILE_DOWNLOAD) + || (event == EVENT_PROACTIVE_HANDLER_AVAILABLE) + || (event == EVENT_EXTERNAL_FILE_UPDATE) + || (event == EVENT_APPLICATION_DESELECT) + || (event == EVENT_FIRST_COMMAND_AFTER_ATR)); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes; + byte testCaseNb; + short[] MonoEventList = new short[1]; + short i; + short j; + + if ((event == EVENT_MENU_SELECTION) && (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier() == (byte)0x01)) { + + j = 0; + + // Build the allowed and supported events list + for(i = MIN_EVENT_NB; i <= MAX_EVENT_NB;i++) { + + if ((this.isEventAllowed(i)) && (this.isEventSupported(i))) { + EventList[j] = i; + j++; + } + } + EventList[j++] = EVENT_UNRECOGNIZED_ENVELOPE; + EventList[j++] = EVENT_PROFILE_DOWNLOAD; + EventList[j++] = EVENT_PROACTIVE_HANDLER_AVAILABLE; + EventList[j++] = EVENT_APPLICATION_DESELECT; + EventList[j] = EVENT_FIRST_COMMAND_AFTER_ATR; + + // ----------------------------------------------------------------- + // Test Case 1: Applet1 registering all eventList buffer + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = false; + + // ----------------------------------------------------------------- + // 1 - For each event in EventList, clearEvent(event) + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + for(j = (short)0; (j < (short)EventList.length); j++) { + obReg.clearEvent(EventList[j]); + } + bRes = true; + } + catch (Exception e) { + bRes = false; + } + + // ----------------------------------------------------------------- + // 2 - setEventList(eventList) + // Offset = 0 + // Length = eventList.length + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + obReg.setEventList(EventList, (short)0, (short)EventList.length); + } + catch (Exception e) { + bRes = false; + } + + // ----------------------------------------------------------------- + // 3 - For all events in eventList isEventSet(event) + // Each time shall return true + // ----------------------------------------------------------------- + for(j = (short)0; (j < MAX_EVENT) && bRes; j++) { + bRes = obReg.isEventSet(EventList[j]); + } + + // ----------------------------------------------------------------- + // 4 - For each event in EventList clearEvent(event) + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + for(j = (short)0; (j < MAX_EVENT) && bRes; j++) { + obReg.clearEvent(EventList[j]); + } + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + + // ----------------------------------------------------------------- + // Test Case 2 : Registering part of eventList buffer + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = true; + + // ----------------------------------------------------------------- + // 1 - setEventList(eventList) + // Offset > 0 + // Length = eventList.lentgh - OFFSET + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + obReg.setEventList(EventList, OFFSET, (short)(MAX_EVENT-OFFSET)); + } + catch (Exception e) { + bRes = false; + } + + // ----------------------------------------------------------------- + // 2 - For all events in eventList isEventSet(event) + // Each time shall return true for events + // ranging from OFFSET to OFFSET+length + // else shall return false + // ----------------------------------------------------------------- + for (j = (short)0; (j < OFFSET) && bRes; j++) { + bRes &= !obReg.isEventSet(EventList[j]); + } + + for(j = (short)OFFSET; (j < MAX_EVENT) && bRes; j++) { + bRes &= obReg.isEventSet(EventList[j]); + } + + // ----------------------------------------------------------------- + // 4 - For each event in EventList clearEvent(event) + // No exception shall be thrown + // ----------------------------------------------------------------- + try { + for(j = (short)OFFSET; (j < MAX_EVENT) && bRes; j++) { + bRes = false; + obReg.clearEvent(EventList[j]); + bRes = true; + } + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3: Null buffer + // EventList = null + // Shall throw a java.lang.NullPointerException exception + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = false; + + try { + obReg.setEventList(null, (short)0, (short)1); + } + catch (java.lang.NullPointerException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4: Out of bounds offset + // Offset = eventList.length + // Length = 1 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)4; + bRes = false; + + try { + obReg.setEventList(EventList, MAX_EVENT, (short)1); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 5: Out of bounds and big offset + // Offset = 255 + // Length = 1 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)5; + bRes = false; + + try { + obReg.setEventList(EventList, (short)255, (short)1); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 6: Offset < 0 + // Offset = -1 + // Length = 1 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)6; + bRes = false; + + try { + obReg.setEventList(EventList, (short)-1, (short)1); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 7: Out of bounds length + // Offset = 0 + // Length = eventList.length + 1 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)7; + bRes = false; + + try { + obReg.setEventList(EventList, (short)0, (short)(MAX_EVENT + 1)); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 8: Out of bounds and big length + // Offset = 0 + // Length = 255 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)8; + bRes = false; + + try { + obReg.setEventList(EventList, (short)0, (short)255); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 9: Length < 0 + // Offset = 0 + // Length = -1 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)9; + bRes = false; + + try { + obReg.setEventList(EventList, (short)0, (short)-1); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 10: Out of bounds offset + Length + // Offset + length > eventList.length + 1 + // Shall throw a java.lang.ArrayIndexOutOfBounds exception + // ----------------------------------------------------------------- + testCaseNb = (byte)10; + bRes = false; + + try { + obReg.setEventList(EventList, OFFSET, MAX_EVENT); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) { + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 11: Event 0 + // Call setEventList with eventList indicating event 0 + // Shall throw a ToolkitException with EVENT_NOT_SUPPORTED reason code + // ----------------------------------------------------------------- + + testCaseNb = (byte)11; + bRes = false; + MonoEventList[(short)0] = (byte)0; + + try { + obReg.setEventList(MonoEventList, (short)0, (short)1); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_SUPPORTED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Cases 12 to 17 + // + // Test Case 12: EVENT_MENU_SELECTION + // Shall throw a ToolkitException + // with EVENT_NOT_ALLOWED reason code + // + // Test Case 13: EVENT_MENU_SELECTION_HELP_REQUEST + // Shall throw a ToolkitException + // with EVENT_NOT_ALLOWED reason code + // + // Test Case 14: EVENT_TIMER_EXPIRATION + // Shall throw a ToolkitException + // with EVENT_NOT_ALLOWED reason code + // + // Test Case 15: EVENT_STATUS_COMMAND + // Shall throw a ToolkitException + // with EVENT_NOT_ALLOWED reason code + // + // Test Case 16: EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + // Shall throw a ToolkitException + // with EVENT_NOT_ALLOWED reason code + // + // Test Case 17: EVENT_EXTERNAL_FILE_UPDATE + // Shall throw a ToolkitException + // with EVENT_NOT_ALLOWED reason code + // + // ----------------------------------------------------------------- + for (j = (short)0; (j < (short)NOT_ALLOWED_SET_EVENTS.length); j++) { + + MonoEventList[(short)0] = NOT_ALLOWED_SET_EVENTS[j]; + bRes = false; + try { + obReg.setEventList(MonoEventList, (short)0, (short)1); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + testCaseNb = (byte)(testCaseNb + 1); // Test Cases : 12-17 + reportTestOutcome(testCaseNb, bRes); + } + + // ----------------------------------------------------------------- + // Test Case 18: Set EVENT_CALL_CONTROL_BY_NAA + // Shall not throw an exception + // ----------------------------------------------------------------- + testCaseNb = (byte)18; + bRes = false; + + try { + obReg.setEventList(List, (short)0, (short)1); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Cases 19: by default + // ----------------------------------------------------------------- + testCaseNb = (byte)19; + bRes = false; + reportTestOutcome(testCaseNb, bRes); + + } else { + if (event == EVENT_CALL_CONTROL_BY_NAA) { + // ----------------------------------------------------------------- + // Test Case 19: Check applet is triggered by an + // ENVELOPE(EVENT_CALL_CONTROL_BY_NAA) + // ----------------------------------------------------------------- + testCaseNb = (byte)19; + bRes = true; + reportTestOutcome(testCaseNb, bRes); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Api_2_Tkr_Sevl_2.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Api_2_Tkr_Sevl_2.java new file mode 100644 index 0000000000000000000000000000000000000000..fc0ec2ea1b8afc7a16272ddfdf361d57e508f36f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Api_2_Tkr_Sevl_2.java @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------------- +// API_2_TKR_SEVL_BSS_2.java +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevl; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setEventList() method + * applet 2 + */ +public class Api_2_Tkr_Sevl_2 extends TestToolkitApplet { + + private static byte[] MenuEntry = {(byte)'A', (byte)'p', (byte)'p', (byte)'l', + (byte)'e', (byte)'t', (byte)'2'}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Sevl_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Api_2_Tkr_Sevl_2 thisApplet = new Api_2_Tkr_Sevl_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuEntry, (short)0, (short)MenuEntry.length, (byte)0, + false, (byte)0, (short)0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes; + byte testCaseNb; + short[] EventList = new short[2]; + + if (EnvelopeHandlerSystem.getTheHandler().getItemIdentifier() == (byte)0x02) { + // ----------------------------------------------------------------- + // Test Case 20: event already assigned + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = false; + + EventList[(short)0] = EVENT_CALL_CONTROL_BY_NAA; + + try { + obReg.setEventList(EventList, (short)0, (short)1); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.EVENT_ALREADY_REGISTERED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 21: Atomicity + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + EventList[(short)1] = EVENT_EVENT_DOWNLOAD_CALL_CONNECTED; + + try { + obReg.setEventList(EventList, (short)0, (short)2); + } + catch (ToolkitException e) { + bRes = (e.getReason()==ToolkitException.EVENT_ALREADY_REGISTERED); + } + catch (Exception e) { + bRes = false; + } + + bRes &= !obReg.isEventSet(EVENT_EVENT_DOWNLOAD_CALL_CONNECTED); + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 22: Multiple registration to the same event + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = false; + + EventList[(short)0] = EVENT_EVENT_DOWNLOAD_MT_CALL; + EventList[(short)1] = EVENT_EVENT_DOWNLOAD_MT_CALL; + + try { + obReg.setEventList(EventList, (short)0, (short)2); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + bRes &= obReg.isEventSet(EVENT_EVENT_DOWNLOAD_MT_CALL); + + reportTestOutcome(testCaseNb, bRes); + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Test_Api_2_Tkr_Sevl.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Test_Api_2_Tkr_Sevl.java new file mode 100644 index 0000000000000000000000000000000000000000..3d837bf01f29a7b37646f44fd6b99d7c1c2eb4b0 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/Test_Api_2_Tkr_Sevl.java @@ -0,0 +1,104 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * isEventSet() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevl; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Sevl extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_sevl"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 20020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 20020102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Sevl() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "10" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0202" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("09010020"); + + // test case 1 to 18: trigger Applet1 + response = test.envelopeMenuSelection("900101", ""); + result = response.checkSw("9000"); + + // test case 19: trigger Applet1 with EVENT_CALL_CONTROL_BY_NAA + test.reset(); + test.terminalProfileSession("09010020 03"); + response = test.envelopeCallControlByNAA(); + result &= response.checkSw("9000"); + + // test case 20 to 22: trigger Applet2 + response = test.envelopeMenuSelection("900102", ""); + result &= response.checkSw("910E"); + response = test.fetch("0E"); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "13CCCCCC CCCCCCCC CCCCCCCC CCCCCCCC" + + "CCCCCCCC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "03CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..fd9c83b3e07e77c1243bb77d04cf46760273005e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/applet.opt @@ -0,0 +1,5 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x02:0x00:0x01 uicc.test.toolkit.api_2_tkr_sevl.Api_2_Tkr_Sevl_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_sevl.Api_2_Tkr_Sevl_1 +uicc.test.toolkit.api_2_tkr_sevl +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/javacard/api_2_tkr_sevl.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/javacard/api_2_tkr_sevl.cap new file mode 100644 index 0000000000000000000000000000000000000000..257f839d22a5099c9ec38721fe2aa50da2102976 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevl/javacard/api_2_tkr_sevl.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_1.java new file mode 100644 index 0000000000000000000000000000000000000000..a68cb18689c3b0299b521efb0832f92595b79a42 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_1.java @@ -0,0 +1,243 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setEvent() method + * applet 1 + */ +public class Api_2_Tkr_Sevt_1 extends TestToolkitApplet { + + // Not allowed events for the setEvent() method + private static short[] NOT_ALLOWED_SET_EVENTS = {EVENT_MENU_SELECTION, EVENT_MENU_SELECTION_HELP_REQUEST, + EVENT_TIMER_EXPIRATION, EVENT_STATUS_COMMAND, + EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION, + EVENT_EXTERNAL_FILE_UPDATE}; + + // Not supported events for the setEvent() method + private static short NOT_SUPPORTED_SETEVENT_10 = 10; + private static short NOT_SUPPORTED_SETEVENT_24 = 24; + + // Event value range + private static short MIN_EVENT_NB = 7; + private static short MAX_EVENT_NB = 29; + + // Events allowed and supported for setEvent() method + private static short MAX_EVENT = 21; // 27 events - 6 not allowed events + private short[] EventList = new short[MAX_EVENT]; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Sevt_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Api_2_Tkr_Sevt_1 thisApplet = new Api_2_Tkr_Sevt_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_EVENT_DOWNLOAD_USER_ACTIVITY + thisApplet.obReg.setEvent(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY); + } + + + /** + * Method called by the processToolkit() method to know if event + * is an allowed event for the clearEvent() or setEvent() method + */ + private boolean isEventAllowed(short event) { + boolean allowed = true; + + for(short i = 0; (i < NOT_ALLOWED_SET_EVENTS.length) && (allowed); i++) { + allowed = (NOT_ALLOWED_SET_EVENTS[i] != event); + } + return allowed; + } + + /** + * Method called by the processToolkit() method to know if event + * is a supported event for the setEvent() method + */ + private boolean isEventSupported(short event) { + return (((event != NOT_SUPPORTED_SETEVENT_10) + &&(event != NOT_SUPPORTED_SETEVENT_24) + && (event >= MIN_EVENT_NB) + && (event <= MAX_EVENT_NB)) + || (event == EVENT_UNRECOGNIZED_ENVELOPE) + || (event == EVENT_PROFILE_DOWNLOAD) + || (event == EVENT_PROACTIVE_HANDLER_AVAILABLE) + || (event == EVENT_EXTERNAL_FILE_UPDATE) + || (event == EVENT_APPLICATION_DESELECT) + || (event == EVENT_FIRST_COMMAND_AFTER_ATR)); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + // Result of tests + boolean bRes; + + // Number of tests + byte testCaseNb = (byte) 0x0B; + + short j = 0; + short eventID; + + // Build the allowed and supported events list + for(short i = MIN_EVENT_NB; i <= MAX_EVENT_NB; i++) { + + if ((this.isEventAllowed(i)) && (this.isEventSupported(i))) { + EventList[j] = i; + j++; + } + } + EventList[j++] = EVENT_UNRECOGNIZED_ENVELOPE; + EventList[j++] = EVENT_PROFILE_DOWNLOAD; + EventList[j++] = EVENT_PROACTIVE_HANDLER_AVAILABLE; + EventList[j++] = EVENT_APPLICATION_DESELECT; + EventList[j] = EVENT_FIRST_COMMAND_AFTER_ATR; + + if (event == EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) { + + // ----------------------------------------------------------------- + // Test Case 1: Applet1 is triggered by envelope(EVENT_EVENT_DOWNLOAD_USER_ACTIVITY) command + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + reportTestOutcome(testCaseNb, true); + + // ----------------------------------------------------------------- + // Test Case 2: For all events defined in ETSI TS 102 241 and allowed, + // clearEvent(event), isEventSet(event), setEvent(event) + // isEventSet(event), clearEvent(event) + // ----------------------------------------------------------------- + testCaseNb = (byte)2; + bRes = false; + + try { + for(short i = 0; i < (short)EventList.length; i++) { + bRes = false; + + if ((this.isEventAllowed(EventList[i])) + && (this.isEventSupported(EventList[i]))) { + + obReg.clearEvent(EventList[i]); + if (obReg.isEventSet(EventList[i])) { + bRes = false; + break; + } + + obReg.setEvent(EventList[i]); + + if (!obReg.isEventSet(EventList[i])) { + bRes = false; + break; + } + + obReg.clearEvent(EventList[i]); + bRes = true; + } else { + bRes = true; + } + } + } + catch (Exception e) { // No exception shall be thrown + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 3: setEvent 0 + // ----------------------------------------------------------------- + testCaseNb = (byte) 3; + bRes = false; + + try { + eventID = (byte) 0; + obReg.setEvent(eventID); + } + catch (ToolkitException e) { // Only EVENT_NOT_SUPPORTED should be thrown + bRes = (e.getReason()==ToolkitException.EVENT_NOT_SUPPORTED); + } + catch (Exception e) { + bRes = false; + } + + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Case 4: Set EVENT_MENU_SELECTION + // Test Case 5: Set EVENT_MENU_SELECTION_HELP_REQUEST + // Test Case 6: Set EVENT_TIMER_EXPIRATION + // Test Case 7: Set EVENT_STATUS_COMMAND + // Test Case 8: Set EVENT_EVENT_DOWNLOAD_LOCAL_CONNECTION + // Test Case 9: Set EVENT_EXTERNAL_FILE_UPDATE + // ----------------------------------------------------------------- + for (short i = (short)(NOT_ALLOWED_SET_EVENTS.length-1); (i > (short) -1); i--) { + + bRes = false; + try { + obReg.setEvent(NOT_ALLOWED_SET_EVENTS[i]); + } + catch (ToolkitException e) { // Only EVENT_NOT_ALLOWED should be thrown + bRes = (e.getReason()==ToolkitException.EVENT_NOT_ALLOWED); + } + catch (Exception e) { + bRes = false; + } + + testCaseNb = (byte)(testCaseNb + 1); // Test Cases: 4-9 + reportTestOutcome(testCaseNb, bRes); + } + reportTestOutcome(testCaseNb, bRes); + + + // ----------------------------------------------------------------- + // Test Case 10: Set EVENT_CALL_CONTROL_BY_NAA + // ----------------------------------------------------------------- + testCaseNb = (byte)10; + bRes = false; + + try { + obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + bRes = true; + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // ----------------------------------------------------------------- + // Test Cases 11: by default + // ----------------------------------------------------------------- + testCaseNb = (byte)11; + reportTestOutcome(testCaseNb, false); + } + else { + if (event == EVENT_CALL_CONTROL_BY_NAA) { + // ----------------------------------------------------------------- + // Test Case 10: Check applet is triggered by an envelope(EVENT_CALL_CONTROL_BY_NAA) + // ----------------------------------------------------------------- + testCaseNb = (byte)11; + reportTestOutcome(testCaseNb, true); + } + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_2.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_2.java new file mode 100644 index 0000000000000000000000000000000000000000..addc4df59136d9d0a86e94165c722ddf62b8248f --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_2.java @@ -0,0 +1,72 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setEvent() method + * applet 2 + */ +public class Api_2_Tkr_Sevt_2 extends TestToolkitApplet { + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'2'}; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Sevt_2() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Sevt_2 thisApplet = new Api_2_Tkr_Sevt_2(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, + (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + boolean bRes ; + byte testCaseNb; + + // ----------------------------------------------------------------- + // Test Case 12: SetEvent(EVENT_CALL_CONTROL_BY_NAA) + // ----------------------------------------------------------------- + testCaseNb = (byte)1; + bRes = false; + try { + obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_ALREADY_REGISTERED); + } + catch (Exception e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_3.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_3.java new file mode 100644 index 0000000000000000000000000000000000000000..c3ed18c55f3a032b8bfefb3c17a28e3a677c14eb --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_3.java @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setEvent() method + * applet 3 + */ +public class Api_2_Tkr_Sevt_3 extends TestToolkitApplet { + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'3'}; + protected static boolean bRes = false; + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Sevt_3() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Sevt_3 thisApplet = new Api_2_Tkr_Sevt_3(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, + (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + byte testCaseNb = (byte) 0x01; + + // ----------------------------------------------------------------- + // Test Case 13: registers to CALL_CONTROL_BY_NAA but it is already + // assigned to another applet in not selectable state + // ----------------------------------------------------------------- + testCaseNb = (byte) 0x01; + try { + obReg.setEvent(EVENT_CALL_CONTROL_BY_NAA); + bRes=false; + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.EVENT_ALREADY_REGISTERED); + } + reportTestOutcome(testCaseNb, bRes); + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_4.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_4.java new file mode 100644 index 0000000000000000000000000000000000000000..823f529477549e01c7d8b0eaceaec14fe77bb0f9 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Api_2_Tkr_Sevt_4.java @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.*; +import javacard.framework.*; +import uicc.test.util.*; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setEvent() method + * applet 4 + */ +public class Api_2_Tkr_Sevt_4 extends TestToolkitApplet { + + private static byte[] MenuInit = {(byte)'A',(byte)'p',(byte)'p',(byte)'l',(byte)'e', (byte)'t',(byte)'4'}; + private byte testCaseNb; + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Sevt_4() { + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + // Create a new applet instance + Api_2_Tkr_Sevt_4 thisApplet = new Api_2_Tkr_Sevt_4(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_MENU_SELECTION + thisApplet.obReg.initMenuEntry(MenuInit, (short) 0, (short) MenuInit.length, + (byte) 0, false, (byte) 0, (short) 0); + } + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + // Result of tests + boolean bRes = false; + + // ----------------------------------------------------------------- + // Test Case 14: applet registers more than once to the same event + // ----------------------------------------------------------------- + testCaseNb = (byte) 0x01; + + // 2- setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL) + try { + obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + bRes=true; + } + catch (ToolkitException e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + bRes=false; + + // 3- setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL) + testCaseNb = (byte) 0x02; + try { + obReg.setEvent(EVENT_EVENT_DOWNLOAD_MT_CALL); + bRes=true; + } + catch (ToolkitException e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + + // 4- isEventSet(EVENT_EVENT_DOWNLOAD_MT_CALL) + testCaseNb = (byte) 0x03; + try { + obReg.isEventSet(EVENT_EVENT_DOWNLOAD_MT_CALL); + bRes=true; + } + catch (ToolkitException e) { + bRes = false; + } + reportTestOutcome(testCaseNb, bRes); + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Test_Api_2_Tkr_Sevt.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Test_Api_2_Tkr_Sevt.java new file mode 100644 index 0000000000000000000000000000000000000000..ace6b29f95e8f5a23fcbe3696a7814714b53e572 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/Test_Api_2_Tkr_Sevt.java @@ -0,0 +1,144 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * isEventSet() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_sevt; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Sevt extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_sevt"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + static final String CLASS_AID_2 = "A0000000 090005FF FFFFFF89 20020001"; + static final String APPLET_AID_2 = "A0000000 090005FF FFFFFF89 20020102"; + static final String CLASS_AID_3 = "A0000000 090005FF FFFFFF89 20030001"; + static final String APPLET_AID_3 = "A0000000 090005FF FFFFFF89 20030102"; + static final String CLASS_AID_4 = "A0000000 090005FF FFFFFF89 20040001"; + static final String APPLET_AID_4 = "A0000000 090005FF FFFFFF89 20040102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Sevt() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = true; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_2, APPLET_AID_2, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0101" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_3, APPLET_AID_3, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0102" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + test.installApplet(CAP_FILE_PATH, CLASS_AID_4, APPLET_AID_4, + "800A" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "01" + // V Maximum number of menu entries + "0103" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + test.terminalProfileSession("090110"); + + // test case 1 to 10: trigger applet1 + test.envelopeEventDownloadUserActivity(); + + // test case 11 + test.envelopeCallControlByNAA(); + + // test case 12: trigger applet2 + test.envelopeMenuSelection("900101",""); + + // test case 13: Set Applet1 in the lock state + test.lockApplication(APPLET_AID_1); + + // trigger applet3 + test.envelopeMenuSelection("900102",""); + + // Set Applet1 in selectable state + test.unlockApplication(APPLET_AID_1); + + // test case 14: trigger applet4 + test.envelopeMenuSelection("900103",""); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + "0BCCCCCC CCCCCCCC CCCCCCCC"); + + response = test.selectApplication(APPLET_AID_2); + result &= response.checkData("10" + APPLET_AID_2 + "01CC"); + + response = test.selectApplication(APPLET_AID_3); + result &= response.checkData("10" + APPLET_AID_3 + "01CC"); + + response = test.selectApplication(APPLET_AID_4); + result &= response.checkData("10" + APPLET_AID_4 + "03CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deleteApplet(APPLET_AID_2); + test.deleteApplet(APPLET_AID_3); + test.deleteApplet(APPLET_AID_4); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..93db0b2e513115ea7e4fee8b467758a16814b6d8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/applet.opt @@ -0,0 +1,7 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x02:0x00:0x01 uicc.test.toolkit.api_2_tkr_sevt.Api_2_Tkr_Sevt_2 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x03:0x00:0x01 uicc.test.toolkit.api_2_tkr_sevt.Api_2_Tkr_Sevt_3 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x04:0x00:0x01 uicc.test.toolkit.api_2_tkr_sevt.Api_2_Tkr_Sevt_4 +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_sevt.Api_2_Tkr_Sevt_1 +uicc.test.toolkit.api_2_tkr_sevt +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/javacard/api_2_tkr_sevt.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/javacard/api_2_tkr_sevt.cap new file mode 100644 index 0000000000000000000000000000000000000000..0f761af787712b3ca6b26d00a693af0c06f4c202 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_sevt/javacard/api_2_tkr_sevt.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/Api_2_Tkr_Smta_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/Api_2_Tkr_Smta_1.java new file mode 100644 index 0000000000000000000000000000000000000000..08485954725fdcafef5540535a2a615bf7943f5e --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/Api_2_Tkr_Smta_1.java @@ -0,0 +1,244 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_smta; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistry interface, setMenuEntryTextAttribute() method + * applet 1 + */ +public class Api_2_Tkr_Smta_1 extends TestToolkitApplet { + + private static byte[] menu1 = { + (byte) 'A', (byte) 'p', (byte) 'p', (byte) 'l', (byte) 'e', (byte)'t',(byte)'1' + }; + + private byte[] textAttribute = { + (byte) 0x00, (byte) 0x0C, (byte) 0x11, (byte) 0x02, + (byte) 0x00, (byte) 0x0C, (byte) 0x10, (byte) 0x03 + }; + + private byte[] shortTextAttribute = { + (byte) 0x00, (byte) 0x0C, (byte) 0x11 + }; + + private boolean bRes = true; + private byte testCaseNb = 1; + + + /** + * Constructor of the applet + */ + public Api_2_Tkr_Smta_1() { + } + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Tkr_Smta_1 thisApplet = new Api_2_Tkr_Smta_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte)bArray[bOffset]); + + // Initialise the data of the test applet + thisApplet.init(); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + + thisApplet.obReg.initMenuEntry(menu1, (short) 0, (short) menu1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(menu1, (short) 0, (short) menu1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(menu1, (short) 0, (short) menu1.length, (byte) 0, false, (byte) 0, (short) 0); + thisApplet.obReg.initMenuEntry(menu1, (short) 0, (short) menu1.length, (byte) 0, false, (byte) 0, (short) 0); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + + if (event == EVENT_UNRECOGNIZED_ENVELOPE) { + + switch (testCaseNb) { + + /** Testcase 1: + * Text attribute update 1 + * No exception shall be thrown. + */ + case 1: + try { + bRes=true; + obReg.setMenuEntryTextAttribute((byte)0x02, textAttribute, (short)0, (short)4); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 2 + * Text attribute update 2 + * No exception shall be thrown. + */ + case 2: + try { + bRes=true; + obReg.setMenuEntryTextAttribute((byte)0x04, textAttribute, (short)4, (short)4); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 3 + * Call setMenuEntryTextAttribute() with null textAttribute + * Shall throw a NullPointerException + */ + case 3: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x04, null, (short)4, (short)4); + } + catch (NullPointerException e) { + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 4 + * DstOffset >= dstBuffer.length + * Shall throw a ArrayIndexOutOfBoundsException + */ + case 4: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x04, textAttribute, (short)8, (short)4); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 5 + * dstOffset < 0 + * Shall throw a ArrayIndexOutOfBoundsException + */ + case 5: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x04, textAttribute, (short)-1, (short)4); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 6 + * DstLength > dstBuffer.length + * Shall throw a ArrayIndexOutOfBoundsException + */ + case 6: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x04, shortTextAttribute, (short)0, (short)4); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 7 + * dstOffset + dstLength > dstBuffer.length + * Shall throw a ArrayIndexOutOfBoundsException + */ + case 7: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x04, textAttribute, (short)5, (short)4); + } + catch (ArrayIndexOutOfBoundsException e) { + bRes=true; + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 8 + * Call setMenuEntryTextAttribute() with Id = 08 + * Shall throw a ToolkitException with MENU_ENTRY_NOT_FOUND reason code + */ + case 8: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x08, textAttribute, (short)0, (short)4); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.MENU_ENTRY_NOT_FOUND); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + + /** Testcase 9 + * Call setMenuEntryTextAttribute() with length = 2 + * Shall throw a ToolkitException with BAD_INPUT_PARAMETER reason code + */ + case 9: + try { + bRes=false; + obReg.setMenuEntryTextAttribute((byte)0x01, textAttribute, (short)0, (short)2); + } + catch (ToolkitException e) { + bRes = (e.getReason() == ToolkitException.BAD_INPUT_PARAMETER); + } + catch (Exception e) { + bRes=false; + } + reportTestOutcome(testCaseNb, bRes); + break; + + } + testCaseNb++; + } + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/Test_Api_2_Tkr_Smta.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/Test_Api_2_Tkr_Smta.java new file mode 100644 index 0000000000000000000000000000000000000000..3e54dd07647546024c7feec914e9969816764cce --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/Test_Api_2_Tkr_Smta.java @@ -0,0 +1,108 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistry interface + * setMenuEntryTextAttribute() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_tkr_smta; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Tkr_Smta extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_tkr_smta"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + + + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Tkr_Smta() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package and applets + test.loadPackage(CAP_FILE_PATH); + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8010" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "0F" + // V Maximum text length for a menu entry + "04" + // V Maximum number of menu entries + "01010202 03030404" + // V Pos./Id. of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + // test script + test.reset(); + response = test.terminalProfile("09010020 00000000 00000000 00000008" + + "00000000 00000000 0000003F 7F"); + + result = response.checkSw("913E"); + response = test.fetch("3E"); + test.terminalResponse("81030125 00820282 81830100"); + + // testcase 1 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9150"); + response = test.fetch("50"); + + result &= response.checkData("D04E8103 01250082 02818285 09554943" + + "43205445 53548F08 01417070 6C657431" + + response.getData().substring(64,66)+ "08024170 706C6574 31"+ //item2 + response.getData().substring(84,86)+ "08034170 706C6574 31"+ //item3 + response.getData().substring(104,106)+"08044170 706C6574 31"+ //item4 + response.getData().substring(124,126)+"10000003 90000C11 02000003 9000000390");//text attribute + + test.terminalResponse("81030125 00820282 81830100"); + // testcase 2 + response = test.unrecognizedEnvelope(); + result &= response.checkSw("9150"); + response = test.fetch("50"); + result &= response.checkData("D04E8103 01250082 02818285 09554943" + + "43205445 53548F08 01417070 6C657431" + + response.getData().substring(64,66)+ "08024170 706C6574 31"+ //item2 + response.getData().substring(84,86)+ "08034170 706C6574 31"+ //item3 + response.getData().substring(104,106)+"08044170 706C6574 31"+ //item4 + response.getData().substring(124,126)+"10000003 90000C11 02000003 90000C1003");//text attribute + + test.terminalResponse("81030125 00820282 81830100"); + + // testcase 3->9 + for (int i = 3; i <= 9; i++) + response = test.unrecognizedEnvelope(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result &= response.checkData("10" + APPLET_AID_1 + + "09CCCCCC CCCCCCCC CCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..e634d68c6868ab03536b53b38e5ba91bef6afdc8 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_tkr_smta.Api_2_Tkr_Smta_1 +uicc.test.toolkit.api_2_tkr_smta +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/javacard/api_2_tkr_smta.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/javacard/api_2_tkr_smta.cap new file mode 100644 index 0000000000000000000000000000000000000000..59bceaab82ba41dc4414bbe7424aa01ab80ca211 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_tkr_smta/javacard/api_2_tkr_smta.cap differ diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/Api_2_Trs_Gety_1.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/Api_2_Trs_Gety_1.java new file mode 100644 index 0000000000000000000000000000000000000000..79d736cb7934b7f02794e9ed4841ebced8af6751 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/Api_2_Trs_Gety_1.java @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_trs_gety; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import uicc.toolkit.* ; +import javacard.framework.* ; +import uicc.test.util.* ; + +/** + * uicc.toolkit package, ToolkitRegistrySystem class, getEntry() method + * applet 1 + */ +public class Api_2_Trs_Gety_1 extends TestToolkitApplet { + + boolean bRes; + byte testCaseNb; + + private ToolkitRegistry Ref; + + /** + * Constructor of the applet + * Test Case 1: Call before register() method + */ + public Api_2_Trs_Gety_1() { + + testCaseNb = (byte)0x01; + try { + Ref = ToolkitRegistrySystem.getEntry(); + if (Ref == null) { + bRes = true; + } else { + bRes = false; + } + } + catch (Exception e) { + bRes = false; + } + } + + + /** + * Method called by the JCRE at the installation of the applet + */ + public static void install(byte bArray[], short bOffset, byte bLength) { + + // Create a new applet instance + Api_2_Trs_Gety_1 thisApplet = new Api_2_Trs_Gety_1(); + + // Register the new applet instance to the JCRE + thisApplet.register(bArray, (short)(bOffset+1), (byte) bArray[bOffset]); + + // Initialise the data of the test applet + // test case 2 + thisApplet.init(); + + // Register test case 1 result + thisApplet.reportTestOutcome(thisApplet.testCaseNb, thisApplet.bRes); + + // check applet ToolkitRegistry reference is not null + thisApplet.testCaseNb = 0x02; + if (thisApplet.obReg == null) { + thisApplet.bRes = false; + } else { + thisApplet.bRes = true; + } + thisApplet.reportTestOutcome(thisApplet.testCaseNb, thisApplet.bRes); + + // Register to EVENT_UNRECOGNIZED_ENVELOPE + thisApplet.obReg.setEvent(EVENT_UNRECOGNIZED_ENVELOPE); + } + + + /** + * Method called by the CAT RE + */ + public void processToolkit(short event) { + + // ----------------------------------------------------------------- + // Test Case 3: The applet calls the getEntry() method again + // ----------------------------------------------------------------- + testCaseNb = (byte)3; + bRes = false; + try { + bRes = (obReg == ToolkitRegistrySystem.getEntry()); + } + catch (Exception e) { + bRes = false ; + } + reportTestOutcome(testCaseNb, bRes) ; + } +} diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/Test_Api_2_Trs_Gety.java b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/Test_Api_2_Trs_Gety.java new file mode 100644 index 0000000000000000000000000000000000000000..e8ee45c5aabdd5e0be4b2c0e1f4d0faae2839c23 --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/Test_Api_2_Trs_Gety.java @@ -0,0 +1,74 @@ +/** + * ETSI TS 102 268: UICC API testing + * uicc.toolkit package part 3 + * Test source for ToolkitRegistrySystem class + * getEntry() method + */ +//----------------------------------------------------------------------------- +// Package Definition +//----------------------------------------------------------------------------- +package uicc.test.toolkit.api_2_trs_gety; + +//----------------------------------------------------------------------------- +// Imports +//----------------------------------------------------------------------------- +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccAPITestCardService; +import org.etsi.scp.wg3.uicc.jcapi.userclass.UiccTestModel; +import org.etsi.scp.wg3.uicc.jcapi.userinterface.APDUResponse; + +public class Test_Api_2_Trs_Gety extends UiccTestModel { + + static final String CAP_FILE_PATH = "uicc/test/toolkit/api_2_trs_gety"; + static final String CLASS_AID_1 = "A0000000 090005FF FFFFFF89 20010001"; + static final String APPLET_AID_1 = "A0000000 090005FF FFFFFF89 20010102"; + private UiccAPITestCardService test; + APDUResponse response; + + public Test_Api_2_Trs_Gety() { + test = UiccAPITestCardService.getTheUiccTestCardService(); + } + + public boolean run() { + + boolean result = false; + + // start test + test.reset(); + test.terminalProfileSession("0101"); + + // install package + test.loadPackage(CAP_FILE_PATH); + // test cases 1 and 2: install applet + test.installApplet(CAP_FILE_PATH, CLASS_AID_1, APPLET_AID_1, + "8008" + // TLV UICC Toolkit application specific parameters + "01" + // V Priority Level + "00" + // V Max. number of timers + "00" + // V Maximum text length for a menu entry + "00" + // V Maximum number of menu entries + "00" + // V Maximum number of channels + "00" + // LV Minimum Security Level field + "00" + // LV TAR Value(s) + "00"); // V Maximum number of services + + + // test script + test.reset(); + test.terminalProfileSession("0901"); + + // test case 3: trigger applet1 + test.unrecognizedEnvelope(); + + // check results + response = test.selectApplication(APPLET_AID_1); + result = response.checkData("10" + APPLET_AID_1 + "03CCCCCC"); + + // delete applet and package + test.reset(); + test.terminalProfileSession("0101"); + test.deleteApplet(APPLET_AID_1); + test.deletePackage(CAP_FILE_PATH); + + return result; + } +} + diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/applet.opt b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/applet.opt new file mode 100644 index 0000000000000000000000000000000000000000..ac788e63dccf653465afc6c26b550c477531282a --- /dev/null +++ b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/applet.opt @@ -0,0 +1,4 @@ +-out EXP CAP JCA +-applet 0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x01:0x00:0x01 uicc.test.toolkit.api_2_trs_gety.Api_2_Trs_Gety_1 +uicc.test.toolkit.api_2_trs_gety +0xa0:0x00:0x00:0x00:0x09:0x00:0x05:0xff:0xff:0xff:0xff:0x89:0x20:0x00:0x00:0x00 1.0 \ No newline at end of file diff --git a/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/javacard/api_2_trs_gety.cap b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/javacard/api_2_trs_gety.cap new file mode 100644 index 0000000000000000000000000000000000000000..4c918855f30f6d5d6535eea70d0a7b076c738c39 Binary files /dev/null and b/source/Annex_E_SourceCode/uicc/test/toolkit/api_2_trs_gety/javacard/api_2_trs_gety.cap differ