trailerBlock.setKey(Key.A, MadConstants.DEFAULT_MAD_KEY);
trailerBlock.setKey(Key.B, writeKeyValue);
trailerBlock.setAccessConditions(MadConstants.READ_WRITE_ACCESS_CONDITIONS);
trailerBlock.setGeneralPurposeByte((byte)(MadConstants.GPB_MAD_AVAILABLE | MadConstants.GPB_MAD_V1));
MfAccess mfAccess = new MfAccess(card, 0, card.getTrailerBlockNumberForSector(0), createKey, createKeyValue);
readerWriter.writeBlock(mfAccess, trailerBlock);
MfAccess mfAccessDataBlock = new MfAccess(card, 0, 1, Key.B, writeKeyValue);
readerWriter.writeBlock(mfAccessDataBlock, new DataBlock(), new DataBlock());
Mad1 mad1 = new Mad1(null, null);
mad1.writeMad();
return mad1;
}
if (card instanceof MfCard4k) {
TrailerBlock trailerBlock = new TrailerBlock();
trailerBlock.setKey(Key.A, MadConstants.DEFAULT_MAD_KEY);
trailerBlock.setKey(Key.B, writeKeyValue);
trailerBlock.setAccessConditions(MadConstants.READ_WRITE_ACCESS_CONDITIONS);
trailerBlock.setGeneralPurposeByte((byte)(MadConstants.GPB_MAD_AVAILABLE | MadConstants.GPB_MAD_V2));
MfAccess mfAccess = new MfAccess(card, 0, card.getTrailerBlockNumberForSector(0), createKey, createKeyValue);
readerWriter.writeBlock(mfAccess, trailerBlock);
MfAccess mfAccessDataBlock = new MfAccess(card, 0, 1, Key.B, writeKeyValue);
readerWriter.writeBlock(mfAccessDataBlock, new DataBlock(), new DataBlock());
MfAccess mfAccess2 = new MfAccess(card, 16, card.getTrailerBlockNumberForSector(16), createKey,
createKeyValue);
readerWriter.writeBlock(mfAccess2, trailerBlock);
MfAccess mfAccessDataBlock2 = new MfAccess(card, 16, 1, Key.B, writeKeyValue);
readerWriter.writeBlock(mfAccessDataBlock2, new DataBlock(), new DataBlock());
Mad2 mad = new Mad2(null, null);
mad.writeMad();