Package javax.smartcardio

Examples of javax.smartcardio.CommandAPDU


   * @see org.kapott.hbci.smartcardio.DDVCardService#calculateSignature(byte[])
   */
  protected byte[] calculateSignature(byte[] data_l)
  {
    putData(0x0100,data_l);
    CommandAPDU command=new CommandAPDU(SECCOS_CLA_SM_PROPR, SECCOS_INS_READ_RECORD,
                                        (byte)0x01, (byte)((0x1B<<3)|0x04),256);
    byte[] data = receive(command);
    byte[] ret = new byte[8];
    System.arraycopy(data,12,ret,0,8);
    return ret;
View Full Code Here


    }
   
    private void selectFile(int fid) {
        byte[] data = {(byte) ((fid >> 8) & 0xFF), (byte) (fid & 0xFF)};
       
        CommandAPDU command = new CommandAPDU(ISO7816_CLA_STD, ISO7816_INS_SELECT_FILE, 0x00, 0x0C, data);
       
        send(command);
    }
View Full Code Here

    private byte[] readBinary(int offset, int length) {
        int p1 = (offset >> 8) & 0x7F;
        int p2 = offset & 0xFF;
        int ne = length == 0 ? 256 : length;
       
        CommandAPDU command = new CommandAPDU(ISO7816_CLA_STD, ISO7816_INS_READ_BINARY, p1, p2, ne);
       
        return receive(command);
    }
View Full Code Here

        byte[] body = new byte[] {(byte) 0x20, (byte) 0x20, (byte) 0x20, (byte) 0x20,
                                  (byte) 0x20, (byte) 0x20, (byte) 0x20, (byte) 0x20};
       
        System.arraycopy(softPin, 0, body, 0, softPin.length);
       
        CommandAPDU command = new CommandAPDU(ISO7816_CLA_STD, ISO7816_INS_VERIFY,
                                              (byte) 0x00, (byte) (ISO7816_PWD_TYPE_DF | pwdId),
                                              body);
        send(command);
    }
View Full Code Here

//        //updateRecordBySFI(0x00, idx, rawData);
    }
   
    public byte[] sign(int idx, byte[] data) {
        // MANAGE SE (activate my sig key)
        send(new CommandAPDU(ISO7816_CLA_STD, 0x22, 0x41, 0xB6 /*signature*/, new byte[]{
                        (byte) 0x84, // private key
                        (byte) 0x01, // length
                        (byte) (0x81 + idx), // kid
                        (byte) 0x83, // public key
                        (byte) 0x01, // length
                        (byte) (0x81 + idx), // kid
                        (byte) 0x80, // algorithm
                        (byte) 0x01, // length
                        (byte) 0x25  // HBCI
                        }));
        // PUT HASH
        send(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x90, 0x81, data));
        // SIGN
        return receive(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x9e, 0x9a, 256));
    }
View Full Code Here

        return receive(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x9e, 0x9a, 256));
    }
   
    public boolean verify(int idx, byte[] data, byte[] sig) {
        // MANAGE SE (activate inst sig key)
        send(new CommandAPDU(ISO7816_CLA_STD, 0x22, 0x41, 0xB6 /*signature*/, new byte[]{
                        (byte) 0x84, // private key
                        (byte) 0x01, // length
                        (byte) (0x81 + idx), // kid
                        (byte) 0x83, // public key
                        (byte) 0x01, // length
                        (byte) (0x91 + idx), // kid
                        (byte) 0x80, // algorithm
                        (byte) 0x01, // length
                        (byte) 0x25  // HBCI
                        }));
        // PUT HASH
        send(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x90, 0x81, data));
        // VERIFY
        try {
            send(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x00, 0xa8, sig));
        } catch (HBCI_Exception e) {
            return false;
        }
        return true;
    }
View Full Code Here

        return true;
    }
   
    public byte[] encipher(int idx, byte[] data) {
        // MANAGE SE (activate inst enc key)
        send(new CommandAPDU(ISO7816_CLA_STD, 0x22, 0x41, 0xB8 /*cipher*/, new byte[]{
                        (byte) 0x84, // private key
                        (byte) 0x01, // length
                        (byte) (0x86 + idx), // kid
                        (byte) 0x83, // public key
                        (byte) 0x01, // length
                        (byte) (0x96 + idx) // kid
                        }));
        // ENCIPHER
        byte[] buffer = receive(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x86, 0x80, data, 256));
        // strip padding indicator
        byte[] result = new byte[buffer.length - 1];
        System.arraycopy(buffer, 1, result, 0, result.length);
        return result;
    }
View Full Code Here

        // insert padding indicator
        byte[] buffer = new byte[data.length + 1];
        buffer[0] = 0;
        System.arraycopy(data, 0, buffer, 1, data.length);
        // MANAGE SE (activate my enc key)
        send(new CommandAPDU(ISO7816_CLA_STD, 0x22, 0x41, 0xB8 /*cipher*/, new byte[]{
                        (byte) 0x84, // private key
                        (byte) 0x01, // length
                        (byte) (0x86 + idx), // kid
                        (byte) 0x83, // public key
                        (byte) 0x01, // length
                        (byte) (0x86 + idx) // kid
        }));
        // DECIPHER
        return receive(new CommandAPDU(ISO7816_CLA_STD, 0x2a, 0x80, 0x86, buffer, 256));
    }
View Full Code Here

  {
    super.init(card);

    // Select AID
    // Kopiert aus org.kapott.hbci.ocf.CardServiceFactory.getCardType
    CommandAPDU command = new CommandAPDU((byte)0x00, (byte)0xa4, (byte)0x04, (byte)0x0c,
                                          new byte[] {(byte)0xd2, (byte)0x76,
                                                      (byte)0x00, (byte)0x00,
                                                      (byte)0x25, (byte)0x48,
                                                      (byte)0x42, (byte)0x02,
                                                      (byte)0x00});
View Full Code Here

        SECCOS_SM_REF_INIT_DATA, (byte)0x08, data_l[0], data_l[1],
        data_l[2], data_l[3], data_l[4], data_l[5],
        data_l[6], data_l[7], SECCOS_SM_VALUE_LE, (byte)0x01,
        (byte)0x00};
   
    CommandAPDU command=new CommandAPDU(SECCOS_CLA_SM1, SECCOS_INS_READ_RECORD,
                                        (byte)0x01, (byte)((0x1B<<3)|0x04),
                                        body, 256);
    byte[] data = receive(command);
    byte[] ret = new byte[8];
    System.arraycopy(data,16,ret,0,8);
View Full Code Here

TOP

Related Classes of javax.smartcardio.CommandAPDU

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.