当前位置: 首页>>代码示例>>Java>>正文


Java CardResponse类代码示例

本文整理汇总了Java中sasc.terminal.CardResponse的典型用法代码示例。如果您正苦于以下问题:Java CardResponse类的具体用法?Java CardResponse怎么用?Java CardResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CardResponse类属于sasc.terminal包,在下文中一共展示了CardResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChallenge

import sasc.terminal.CardResponse; //导入依赖的package包/类
/**
 * EMV 4.2 Book 3, section 6.5.6
 * The GET CHALLENGE command is used to obtain an unpredictable number from 
 * the ICC for use in a security-related procedure. 
 * The challenge shall be valid only for the next issued command.
 * 
 * Used eg when enciphering the PIN
 * 
 * @return an 8-byte unpredictable number generated by the ICC, 
 *    or a zero length byte array if the card does not support the command or the response data length != 8 
 * @throws TerminalException 
 */
private byte[] getChallenge() throws TerminalException {

    byte[] command;

    Log.commandHeader("Send GET CHALLENGE command");
    command = EMVAPDUCommands.getChallenge();

    //Parse raw bytes only, no BERTLV
    CardResponse getChallengeResponse = EMVUtil.sendCmdNoParse(terminal, command);
    
    
    if (getChallengeResponse.getSW() == SW.SUCCESS.getSW()) {
        //The data field of the response message should contain an 
        //8-byte unpredictable number generated by the ICC
        byte[] challenge = getChallengeResponse.getData();
        return challenge;
    }
    return new byte[0];
}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:32,代码来源:EMVSession.java

示例2: readPINTryCounter

import sasc.terminal.CardResponse; //导入依赖的package包/类
public void readPINTryCounter() throws TerminalException {

        EMVApplication app = card.getSelectedApplication();

        verifyAppInitialized(app);

        byte[] command;
        int SW1;
        int SW2;

        Log.commandHeader("Send GET DATA command to find the PIN Try Counter");
        command = EMVAPDUCommands.getPINTryConter();
        CardResponse getDataPINTryCounterResponse = EMVUtil.sendCmd(terminal, command);

        SW1 = (byte) getDataPINTryCounterResponse.getSW1();
        SW2 = (byte) getDataPINTryCounterResponse.getSW2();

        if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
            BERTLV tlv = TLVUtil.getNextTLV(new ByteArrayInputStream(getDataPINTryCounterResponse.getData()));
            app.setPINTryCounter(tlv.getValueBytes()[0]);
        } else {
            app.setPINTryCounter(-2);
        }
    }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:25,代码来源:EMVSession.java

示例3: externalAuthenticate

import sasc.terminal.CardResponse; //导入依赖的package包/类
/**
 *
 * @param cryptogram mandatory 8 bytes from issuer
 * @param proprietaryData optional 1-8 bytes (proprietary)
 * @throws TerminalException
 */
public void externalAuthenticate(byte[] cryptogram, byte[] proprietaryData) throws TerminalException {

    EMVApplication app = card.getSelectedApplication();

    verifyAppInitialized(app);

    byte[] command;

    Log.commandHeader("Send EXTERNAL AUTHENTICATE command");

    command = EMVAPDUCommands.externalAuthenticate(cryptogram, proprietaryData);
    CardResponse externalAuthenticateResponse = EMVUtil.sendCmd(terminal, command);
    //No data field is returned in the response message
    //'9000' indicates a successful execution of the command.
    //'6300' indicates "Issuer authentication failed".

    if (externalAuthenticateResponse.getSW() != SW.SUCCESS.getSW()) {
        if (externalAuthenticateResponse.getSW() == SW.AUTHENTICATION_FAILED.getSW()) {
            throw new SmartCardException("Issuer authentication failed");
        }
        throw new SmartCardException("Unexpected response: " + Util.short2Hex(externalAuthenticateResponse.getSW()));
    }
}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:30,代码来源:EMVSession.java

示例4: readTransactionLog

import sasc.terminal.CardResponse; //导入依赖的package包/类
/**
 * Based on a patch by Thomas Souvignet -FR-
 */
private void readTransactionLog(EMVApplication app) throws TerminalException {
    //read all the log records
    LogEntry logEntry = app.getLogEntry();
    int sfi = logEntry.getSFI().getValue();
    for (int recordNum = 1; recordNum <= logEntry.getNumberOfRecords(); recordNum++) {
        Log.commandHeader("Send READ RECORD to read LOG ENTRY SFI " + sfi + " record " + recordNum);

        byte[] command = EMVAPDUCommands.readRecord(recordNum, logEntry.getSFI().getValue());

        CardResponse readAppDataResponse = EMVUtil.sendCmdNoParse(terminal, command);

        byte SW1 = (byte) readAppDataResponse.getSW1();
        byte SW2 = (byte) readAppDataResponse.getSW2();

        if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
            app.addTransactionLogRecord(readAppDataResponse.getData());
        } else if (SW1 == (byte) 0x6a && SW2 == (byte) 0x83) {
            return;
        } else {
            //Any SW1 SW2 other than '9000' passed to the application layer as a result
            //of reading any record shall cause the transaction (not entry log) to be terminated [spec]
            throw new SmartCardException("Reading application data failed for SFI " + sfi + " Record Number: " + recordNum);
        }
    }
}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:29,代码来源:EMVSession.java

示例5: main

import sasc.terminal.CardResponse; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    AID aid = new AID("A0 00 00 01 67 41 30 00 FF");
    JCOPApplication jcopApp = new JCOPApplication(aid, Util.fromHexString("B3 11 01 29 00 00 00 00 50 48 36 35 30 41 01 03 C1 3C 82"), null);
    System.out.println(jcopApp);
    
    CardConnection cardConnection = TerminalUtil.connect(TerminalUtil.State.CARD_INSERTED); //Waits for card insertion
    Log.info(Util.prettyPrintHexNoWrap(cardConnection.getATR()));
    Log.info(ATR_DB.searchATR(cardConnection.getATR()).toString());
    
    CardResponse selectJcopResponse = cardConnection.transmit(Util.fromHexString("00 a4 04 00 09 a0 00 00 01 67 41 30 00 ff 00"));
    System.out.println(selectJcopResponse);
    System.out.println(new JCOPApplication(aid, selectJcopResponse.getData(), null));

}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:15,代码来源:JCOPApplication.java

示例6: transmit

import sasc.terminal.CardResponse; //导入依赖的package包/类
private CardResponse transmit(byte[] command, String description)
		throws TerminalException {
	Log.d(App.TAG, description);
	CardResponse response = App.seConn.transmit(command);
	EMVUtil.printResponse(response, true);

	return response;
}
 
开发者ID:gsbabil,项目名称:ClassicNFC,代码行数:9,代码来源:MainActivity.java

示例7: initCard

import sasc.terminal.CardResponse; //导入依赖的package包/类
public SmartCard initCard() throws TerminalException {

        if (cardInitialized) {
            throw new SmartCardException("Card already initalized. Create new Session to init new card.");
        }

        card = new SmartCard(new sasc.iso7816.ATR(terminal.getATR()));
        Log.debug("terminal: " + terminal);
        Log.debug("ATR: " + Util.prettyPrintHexNoWrap(terminal.getATR()));

        byte[] command;
        int SW1;
        int SW2;

        try {
            Thread.sleep(sessionEnv.getInitialPauseMillis());
        } catch (InterruptedException ex) {
            ex.printStackTrace(System.err);
            Thread.currentThread().interrupt();
            throw new TerminalException(ex);
        }

        if (sessionEnv.getWarmUpCard()) {
            //Some cards/readers seem to misbehave on the first command 
            //(maybe due to premature activation after insertion?)
            //eg if the first command is "select PSE", then the card might
            //return 6985 (Command not allowed; conditions of use not satisfied)
            //We try to work around this by sending a "warm up" command to the card

            Log.commandHeader("SELECT FILE NONEXISTINGFILE to warm up the card/terminal/connection");

            command = EMVAPDUCommands.selectByDFName(Util.fromHexString("4E 4F 4E 45 58 49 53 54 49 4E 47 46 49 4C 45"));

            CardResponse selectNEFResponse = EMVUtil.sendCmd(terminal, command);

            SW1 = (byte) selectNEFResponse.getSW1();
            SW2 = (byte) selectNEFResponse.getSW2();

            //NO-OP
        }

        CardScanner scanner = new CardScanner(card, terminal, sessionEnv);
        scanner.start();

        return card;
    }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:47,代码来源:CardSession.java

示例8: process

import sasc.terminal.CardResponse; //导入依赖的package包/类
@Override
public boolean process(SmartCard card, CardConnection terminal) throws TerminalException {
    Log.debug("Attempting to read storage card");
    
    byte SW1;
    byte SW2;
    byte[] command;
    CardResponse response;
    byte[] data;
    
    //6a 81 = Function not supported
    //90 00 = Success 
    Log.commandHeader("PS/SC GET DATA: UID (Command handled by terminal when card is contactless)");

    command = Util.fromHexString("ff ca 00 00 00"); //PC/SC 2.01 part 3 GetData: UID
    response = EMVUtil.sendCmdNoParse(terminal, command);
    SW1 = (byte) response.getSW1();
    SW2 = (byte) response.getSW2();
    if (response.getSW() == SW.SUCCESS.getSW()) {
        
    }
    
    Log.commandHeader("PC/SC GET DATA: Historical bytes (Command handled by terminal when card is contactless)");

    command = Util.fromHexString("ff ca 01 00 00"); //PC/SC 2.01 part 3 GetData: historical bytes from the ATS of a ISO 14443 A card without CRC
    response = EMVUtil.sendCmdNoParse(terminal, command);
    SW1 = (byte) response.getSW1();
    SW2 = (byte) response.getSW2();
    if (response.getSW() == SW.SUCCESS.getSW()) {
        
    }
    
    //Read Binary

    //    Warning
    //      6281 Part of returned data may be corrupted.
    //        82 End of file reached before reading expected number of bytes.
    //      6981 Command incompatible.
    //        82 Security status not satisfied.
    //        86 Command not allowed.
    //      6A81 Function not supported.
    //        82 File not found / Addressed block or byte does not exist.
    //
    //    Error
    //      6CXX Wrong length (wrong number Le; 'XX' is the exact number). 
    
    int addressMSB = 0;
    int addressLSB = 0;
    while(addressMSB < 256) {
        Log.commandHeader("PC/SC Read Binary (Storage Card)");
        command = Util.fromHexString("FF B0 00 00 00"); //with Le
        command[2] = (byte)addressMSB;
        command[3] = (byte)addressLSB;
        response = EMVUtil.sendCmdNoParse(terminal, command);
        SW1 = response.getSW1();
        SW2 = response.getSW2();
        data = response.getData();
        if(data.length > 0 && response.getSW() == SW.SUCCESS.getSW()){
            addressLSB++;
            if(addressLSB > 255) {
                addressLSB = 0;
                addressMSB++;
            }
            continue;
        }
        break;
    } 
    return false; //Don't handle exclusively. The card may have more applications or other functionality
}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:70,代码来源:StorageCardHandler.java

示例9: selectApplication

import sasc.terminal.CardResponse; //导入依赖的package包/类
public void selectApplication(EMVApplication app) throws TerminalException {

        if (app == null) {
            throw new IllegalArgumentException("Parameter 'app' cannot be null");
        }
        if (!contextInitialized) {
            throw new SmartCardException("Card not initialized. Call initCard() first");
        }
        EMVApplication currentSelectedApp = card.getSelectedApplication();
        if (currentSelectedApp != null && app.getAID().equals(currentSelectedApp.getAID())) {
            throw new SmartCardException("Application already selected. AID: " + app.getAID());
        }

        AID aid = app.getAID();
        byte[] command;

        Log.commandHeader("Select application by AID");
        command = EMVAPDUCommands.selectByDFName(aid.getAIDBytes());

        CardResponse selectAppResponse = EMVUtil.sendCmd(terminal, command);

        if (selectAppResponse.getSW() == SW.SELECTED_FILE_INVALIDATED.getSW()) {
            //App blocked
            Log.info("Application BLOCKED");
            //TODO abort execution if app blocked?
            //throw new SmartCardException("EMVApplication " + Util.byteArrayToHexString(aid.getAIDBytes()) + " blocked");
        }

        EMVUtil.parseFCIADF(selectAppResponse.getData(), app);

        //Example Response from previous command:
        //      6f 37
        //      84 07 //AID
        //            a0 00 00 00 03 10 10
        //      a5 2c
        //            50 04 //Application Label (= VISA)
        //                  56 49 53 41
        //            87 01 //Application priority indicator
        //                  02
        //            9f 38 06 //PDOL
        //                     9f 1a
        //                           02
        //                     5f 2a
        //                           02
        //            5f 2d 04 //Language Preference
        //                     6e 6f 65 6e (= no en)
        //            9f 11 01 //Issuer code table index
        //                     01
        //            9f 12 0c //Application Preferred name
        //                     56 49 53 41 20 43 6c 61 73 73 69 63 (= VISA Classic)



        //The card supplies the PDOL (if present) to the terminal as part of the FCI
        //provided in response to the SELECT FILE (Application Definition File) command

        //If PDOL present, the ICC requires parameters from the Terminal.
        //In this specific example:
        //9F1A = Indicates the country code of the terminal, represented according to ISO 3166
        //578 Norway = 0x0578
        //5F2A = Transaction Currency Code: Indicates the currency code of the transaction according to ISO 4217 (numeric 3)
        //NORWAY  Norwegian Krone  NOK  578  == 0x0578
        //PDOL response data (used in the GET PROCESSING OPTS command) = 05 78 05 78

        getCard().setSelectedApplication(app);

    }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:68,代码来源:EMVSession.java

示例10: processVerifyPIN

import sasc.terminal.CardResponse; //导入依赖的package包/类
private boolean processVerifyPIN(boolean encipherPin) throws TerminalException {

        EMVApplication app = card.getSelectedApplication();
        
        if(app.getPINTryCounter() == -1) { //-1 means we have not tried reading the PIN Try Counter before
            readPINTryCounter();
        }
        
        if(app.getPINTryCounter() == 0) {
            Log.debug("PIN Try limit exeeded. Unable to verify PIN.");
            EMVTerminal.getTerminalVerificationResults().setPinTryLimitExceeded(true);
            return false;
        }
        
        byte[] command;
        
        while(app.getPINTryCounter() != 0) {
        
            PasswordCallback pinInput = EMVTerminal.getPinInput();
            
            char[] pin = pinInput.getPassword();
            pinInput.clearPassword();
            
            if(pin == null) { //Input aborted by user or failed
                Log.debug("PIN input aborted or failed.");
                return false;
            }
            
            if(encipherPin) {                
                //Recover the public key to be used for PIN encipherment
                ICCPublicKeyCertificate iccPKCert = app.getICCPublicKeyCertificate();
                if(iccPKCert == null || !iccPKCert.validate() || iccPKCert.getICCPublicKey() == null) {
                    Log.debug("Unable to encipher PIN: ICC Public Key Certificate not valid");
                    return false;
                }
                
                //Get unpredictable number from ICC
                byte[] challenge = getChallenge();
                if(challenge.length != 8) {
                    Log.debug("Unable to encipher PIN: GET CHALLENGE returned response length "+challenge.length);
                    return false;
                }
                
                //TODO encipher PIN
            }
            
            command = EMVAPDUCommands.verifyPIN(pin, !encipherPin);
            Arrays.fill(pin, ' ');
            
            Log.commandHeader("Send VERIFY (PIN) command");

            CardResponse verifyResponse = EMVUtil.sendCmd(terminal, command);

            if (verifyResponse.getSW() == SW.SUCCESS.getSW()) {
                //Try to update PTC
                if(app.getPINTryCounter() != -2) { //-2 means app does not support the command
                    readPINTryCounter();
                }
                return true;
            } else {
                if (verifyResponse.getSW() == SW.COMMAND_NOT_ALLOWED_AUTHENTICATION_METHOD_BLOCKED.getSW()
                        || verifyResponse.getSW() == SW.COMMAND_NOT_ALLOWED_REFERENCE_DATA_INVALIDATED.getSW()) {
                    Log.info("No more retries left. CVM blocked");
                    EMVTerminal.getTerminalVerificationResults().setPinTryLimitExceeded(true);
                    app.setPINTryCounter(0);
                    return false;
                } else if (verifyResponse.getSW1() == (byte) 0x63 && (verifyResponse.getSW2() & (byte)0xF0) == (byte) 0xC0) {
                    int numRetriesLeft = (verifyResponse.getSW2() & 0x0F);
                    Log.info("Wrong PIN. Retries left: "+numRetriesLeft);
                    app.setPINTryCounter(numRetriesLeft);
                } else {
                    String description = SW.getSWDescription(verifyResponse.getSW());
                    Log.info("Application returned unexpected Status: 0x"+Util.short2Hex(verifyResponse.getSW()) 
                            + (description != null && !description.isEmpty()?" ("+description+")":""));
                    return false;
                }
            }
        }
        EMVTerminal.getTerminalVerificationResults().setPinTryLimitExceeded(true);
        return false;
    }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:82,代码来源:EMVSession.java

示例11: internalAuthenticate

import sasc.terminal.CardResponse; //导入依赖的package包/类
private void internalAuthenticate(EMVApplication app) throws TerminalException {

        if(!canDDABePerformed(app)){
            EMVTerminal.getTerminalVerificationResults().setDDAFailed(true);
            return;
        }
        
        if (app.getSignedDynamicApplicationData() != null) {
            throw new SmartCardException("Signed Dynamic Application Data exists. DDA already performed?");
        }
        
        byte[] command;
        int SW1;
        int SW2;

        Log.commandHeader("Send INTERNAL AUTHENTICATE command");

        byte[] authenticationRelatedData = null; //data according to DDOL

        DOL ddol = app.getDDOL();
        if (ddol != null) {
            authenticationRelatedData = EMVTerminal.constructDOLResponse(ddol, app);
        }
        if (authenticationRelatedData == null) {
            authenticationRelatedData = EMVTerminal.getDefaultDDOLResponse(app);
        }

        command = EMVAPDUCommands.internalAuthenticate(authenticationRelatedData);
        //The data field of the command message contains the authentication-related data proprietary to an application. 
        //It is coded according to the DDOL as defined in Book 2.

        //The response contains the "Signed Dynamic EMVApplication Data"
        //See Table 15, book 2 (page 79)
        CardResponse internalAuthenticateResponse = EMVUtil.sendCmd(terminal, command);

        SW1 = (byte) internalAuthenticateResponse.getSW1();
        SW2 = (byte) internalAuthenticateResponse.getSW2();

        if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
            EMVUtil.processInternalAuthResponse(internalAuthenticateResponse.getData(), authenticationRelatedData, app);
            
        }
    }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:44,代码来源:EMVSession.java

示例12: generateAC

import sasc.terminal.CardResponse; //导入依赖的package包/类
public void generateAC(byte[] iccDynamicNumber) throws TerminalException {
    /**
     * p1 &= 0b00111111 = AAC = reject transaction (EMVApplication Authentication Cryptogram)
     * p1 &= 0b10111111 = TC = proceed offline (Transaction Certificate)
     * p1 &= 0b01111111 = ARQC = go online (Authorization Request Cryptogram                                                                            ) +
     * 0x00 = CDA signature not requested
     * 0x10 = CDA signature requested
     */

    EMVApplication app = card.getSelectedApplication();

    verifyAppInitialized(app);

    byte[] command;

    Log.commandHeader("Send GENERATE APPLICATION CRYPTOGRAM command");

    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    byte[] authorizedAmount = Util.fromHexString("00 00 00 00 00 01");
    byte[] secondaryAmount = Util.fromHexString("00 00 00 00 00 00");
    byte[] tvr = Util.fromHexString("00 00 00 00 00");
    byte[] transactionCurrencyCode = Util.fromHexString("09 78");
    byte[] transactionDate = Util.fromHexString("09 07 30");
    byte[] transactionType = Util.fromHexString("21");
    byte[] terminalUnpredictableNumber = Util.generateRandomBytes(4);
    //iccDynamicNumber
    byte[] dataAuthCode = app.getSignedStaticApplicationData().getDataAuthenticationCode();

    buf.write(authorizedAmount, 0, authorizedAmount.length);
    buf.write(secondaryAmount, 0, secondaryAmount.length);
    buf.write(tvr, 0, tvr.length);
    buf.write(transactionCurrencyCode, 0, transactionCurrencyCode.length);
    buf.write(transactionDate, 0, transactionDate.length);
    buf.write(transactionType, 0, transactionType.length);
    buf.write(terminalUnpredictableNumber, 0, terminalUnpredictableNumber.length);
    buf.write(iccDynamicNumber, 0, iccDynamicNumber.length);
    buf.write(dataAuthCode, 0, dataAuthCode.length);

    //0x40 = TC
    //0x80 = ARQC
    command = EMVAPDUCommands.generateAC((byte) 0x40, buf.toByteArray());
    CardResponse generateACResponse = EMVUtil.sendCmd(terminal, command);
    //'9000' indicates a successful execution of the command.

    if (generateACResponse.getSW() != SW.SUCCESS.getSW()) {
        throw new SmartCardException("Unexpected response: " + Util.short2Hex(generateACResponse.getSW()));
    } else {
        //TODO
        Log.info("TODO GenerateAC success");

        //80 response message template 1 contatenated values
        //77 BER-TLV encoded
    }
}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:55,代码来源:EMVSession.java

示例13: checkForTransactionLogRecords

import sasc.terminal.CardResponse; //导入依赖的package包/类
/**
  * This is an optional command that can be issued (when?)
  * 
  * @throws TerminalException 
  */
 public void checkForTransactionLogRecords() throws TerminalException {
     
     EMVApplication app = card.getSelectedApplication();

     verifyAppInitialized(app);

     if(app.isTransactionLogProcessed()) {
         throw new SmartCardException("Transaction Log has already been processed");
     }
     
     app.setTransactionLogProcessed();
     
     byte[] command;
     int SW1;
     int SW2;
     
     //If the Log Entry data element is present in the FCI Issuer Discretionary Data,
     //then get the Log Format (and proceed to read the log records...)
     Log.commandHeader("Send GET DATA command to find the Log Format");
     command = EMVAPDUCommands.getLogFormat();
     CardResponse getDataLogFormatResponse = EMVUtil.sendCmd(terminal, command);

     SW1 = (byte) getDataLogFormatResponse.getSW1();
     SW2 = (byte) getDataLogFormatResponse.getSW2();

     if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
         BERTLV tlv = TLVUtil.getNextTLV(new ByteArrayInputStream(getDataLogFormatResponse.getData()));
         app.setLogFormat(new LogFormat(tlv.getValueBytes()));

         //Log Entry data element should be located in the FCI Issuer Discretionary Data
         //If it is not, then the app does not support transaction logging.
         //But we try to read the Log Entry with GET DATA if not present in FCI
         if (app.getLogEntry() != null) {
             readTransactionLog(app);
         } else {
	Log.commandHeader("Send GET DATA command to find the Log Entry SFI");
	command = EMVAPDUCommands.getData((byte)0x9f, (byte)0x4d);
	CardResponse getDataLogEntryResponse = EMVUtil.sendCmd(terminal, command);

	SW1 = (byte) getDataLogEntryResponse.getSW1();
	SW2 = (byte) getDataLogEntryResponse.getSW2();

     		if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
		app.setLogEntry(new LogEntry(getDataLogEntryResponse.getData()[0], getDataLogEntryResponse.getData()[1]));
		readTransactionLog(app);
	}
}

     }
 }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:56,代码来源:EMVSession.java

示例14: testBruteForceRecords

import sasc.terminal.CardResponse; //导入依赖的package包/类
/**
     * This method is only for debugging. Not to be used in normal processing
     * 
     * @throws TerminalException 
     */
    public void testBruteForceRecords() throws TerminalException {

        EMVApplication app = card.getSelectedApplication();

        if (app == null) {
            throw new SmartCardException("No application selected. Call selectApplication(Application) and initializeApplicationProcessing() first");
        }

        byte[] command;
        byte SW1;
        byte SW2;

        Log.commandHeader("Brute force SFI & Record numbers (Send READ RECORD)");

        //Valid SFI: 1 to 30
        //Valid Record numbers: 1 to 255

        int numRecordsFound = 0;

        for (int sfi = 1; sfi <= 30; sfi++) {

            for (int recordNum = 1; recordNum <= 255; recordNum++) {

                command = EMVAPDUCommands.readRecord(recordNum, sfi);

                CardResponse readRecordsResponse = EMVUtil.sendCmd(terminal, command);

                SW1 = (byte) readRecordsResponse.getSW1();
                SW2 = (byte) readRecordsResponse.getSW2();

                if (SW1 == (byte) 0x90 && SW2 == (byte) 0x00) {
//                if (SW1 != (byte) 0x6a && (SW2 != (byte) 0x83 || SW2 != (byte) 0x82)) { //This is used to see if we can get any other responses
                    System.out.println("***** BRUTE FORCE FOUND SOMETHING ***** SFI=" + Util.byte2Hex((byte) sfi) + " File=" + recordNum + " SW=" + Util.short2Hex(readRecordsResponse.getSW()));
                    System.out.println(Util.prettyPrintHex(readRecordsResponse.getData()));
                    EMVUtil.parseAppRecord(readRecordsResponse.getData(), app);
                    numRecordsFound++;
                }
            }
        }
        System.out.println("Number of Records found: " + numRecordsFound);
    }
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:47,代码来源:EMVSession.java

示例15: sendCmd

import sasc.terminal.CardResponse; //导入依赖的package包/类
public static CardResponse sendCmd(CardConnection terminal, byte[] cmd) throws TerminalException {
    return sendCmdInternal(terminal, cmd, true);
}
 
开发者ID:yinheli,项目名称:javaemvreader,代码行数:4,代码来源:EMVUtil.java


注:本文中的sasc.terminal.CardResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。