Examples of MfClassicAccess


Examples of org.nfctools.mf.classic.MfClassicAccess

    MemoryLayout memoryLayout = readerWriter.getMemoryLayout();

    for (int sectorId = 0; sectorId < memoryLayout.getSectors(); sectorId++) {
      for (byte[] key : knownKeys) {
        try {
          MfClassicAccess access = new MfClassicAccess(new KeyValue(Key.A, key), sectorId, 0,
              memoryLayout.getBlocksPerSector(sectorId));
          MfBlock[] mfBlock = readerWriter.readBlock(access);
          for (int blockId = 0; blockId < mfBlock.length; blockId++) {
            System.out.println("S" + sectorId + "|B" + blockId + " Key: " + NfcUtils.convertBinToASCII(key)
                + " " + mfBlock[blockId]);
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

  public void initMadTrailer(int madVersion) throws MfException, IOException {
    super.initMadTrailer(madVersion);
    trailerBlock = createTrailer(keyConfig.getWriteKeyValue());
    trailerBlock.setGeneralPurposeByte(MadConstants.GPB_MAD_2_TRAILER);

    MfClassicAccess accessTrailer = new MfClassicAccess(new KeyValue(keyConfig.getCreateKey(),
        keyConfig.getCreateKeyValue()), 16, memoryLayout.getTrailerBlockNumberForSector(16));
    readerWriter.writeBlock(accessTrailer, trailerBlock);
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

  }

  protected void readMad(byte[] madData, int sectorId, int firstBlockId, TrailerBlock trailerBlock)
      throws IOException {
    int blocksToRead = madData.length / MfConstants.BYTES_PER_BLOCK;
    MfClassicAccess access = new MfClassicAccess(new KeyValue(Key.A, trailerBlock.getKey(Key.A)), sectorId,
        firstBlockId, blocksToRead);
    MfBlock[] madBlocks = readerWriter.readBlock(access);
    for (int x = 0; x < blocksToRead; x++) {
      System.arraycopy(madBlocks[x].getData(), 0, madData, x * MfConstants.BYTES_PER_BLOCK,
          MfConstants.BYTES_PER_BLOCK);
 
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

      byte[] writeBuffer = new byte[MfConstants.BYTES_PER_BLOCK];
      System.arraycopy(madData, x * MfConstants.BYTES_PER_BLOCK, writeBuffer, 0, MfConstants.BYTES_PER_BLOCK);
      dataBlocks[x] = new DataBlock(writeBuffer);
    }

    MfClassicAccess access = new MfClassicAccess(new KeyValue(Key.B, trailerBlock.getKey(Key.B)), sectorId,
        firstBlockId);
    readerWriter.writeBlock(access, dataBlocks);
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

    return crc.getCrc();
  }

  protected void writeTrailer(int trailerSectorId, TrailerBlock trailerBlock) throws IOException {
    MfClassicAccess accessTrailer = new MfClassicAccess(new KeyValue(keyConfig.getCreateKey(),
        keyConfig.getCreateKeyValue()), trailerSectorId,
        memoryLayout.getTrailerBlockNumberForSector(trailerSectorId));
    readerWriter.writeBlock(accessTrailer, trailerBlock);
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

  }

  private void writeBlock(Key writeKey, byte[] writeKeyValue, TrailerBlock trailerBlock, int sectorId)
      throws IOException {

    MfClassicAccess access = new MfClassicAccess(new KeyValue(writeKey, writeKeyValue), sectorId,
        memoryLayout.getTrailerBlockNumberForSector(sectorId));

    readerWriter.writeBlock(access, trailerBlock);
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

  public static ApplicationDirectory initInstance(MfClassicReaderWriter readerWriter, MadKeyConfig keyConfig)
      throws IOException {
    byte[] writeKeyValue = keyConfig == null ? null : keyConfig.getWriteKeyValue();
    MemoryLayout memoryLayout = readerWriter.getMemoryLayout();
    MfClassicAccess accessTrailer = new MfClassicAccess(MfClassicConstants.MAD_KEY, 0,
        memoryLayout.getTrailerBlockNumberForSector(0));
    TrailerBlock madTrailer = (TrailerBlock)readerWriter.readBlock(accessTrailer)[0];

    if ((madTrailer.getGeneralPurposeByte() & MadConstants.GPB_MAD_AVAILABLE) != 0) {
      if ((madTrailer.getGeneralPurposeByte() & MadConstants.GPB_MAD_V1) == MadConstants.GPB_MAD_V1) {
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

  private TrailerBlock readTrailerBlock(MfClassicReaderWriter readerWriter, int sectorId) throws IOException {
    MemoryLayout memoryLayout = readerWriter.getMemoryLayout();
    for (byte[] key : knownKeys) {
      try {
        MfClassicAccess access = new MfClassicAccess(new KeyValue(Key.A, key), sectorId,
            memoryLayout.getTrailerBlockNumberForSector(sectorId));
        MfBlock[] readBlock = readerWriter.readBlock(access);
        return (TrailerBlock)readBlock[0];
      }
      catch (MfLoginException e) {
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

          try {
            initTransportConfig(readerWriter, sectorId, new KeyValue(keyToWrite, key));
            for (int blockId = 0; blockId < memoryLayout.getBlocksPerSector(sectorId); blockId++) {
              if (!memoryLayout.isTrailerBlock(sectorId, blockId) && !(blockId == 0 && sectorId == 0)) {
                log.info("Cleaning S" + sectorId + "|B" + blockId);
                MfClassicAccess access = new MfClassicAccess(new KeyValue(Key.A,
                    MfConstants.TRANSPORT_KEY), sectorId, blockId);
                readerWriter.writeBlock(access, emptyDataBlock);
              }
            }
            log.info("Sector " + sectorId + " clear with key: " + NfcUtils.convertBinToASCII(key));
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicAccess

  public static void initTransportConfig(MfClassicReaderWriter readerWriter, int sector, KeyValue keyValue)
      throws IOException {
    MemoryLayout memoryLayout = readerWriter.getMemoryLayout();
    TrailerBlock transportTrailer = new TrailerBlock();
    MfClassicAccess access = new MfClassicAccess(keyValue, sector,
        memoryLayout.getTrailerBlockNumberForSector(sector));
    readerWriter.writeBlock(access, transportTrailer);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.