×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    27

    NFC + DESFire Security

    Hi all,

    When you establish a DESFireConnection to a DESFire Card there are many nice methods already implemented to communicate with the card (creating applications, creating files,...). BUT the only thing that is missing (in my opinion) is the AUTHENTICATION, or is it not??

    The only thing there is, is com.nokia.nfc.nxp.desfire.DESFireSecurity.getAuthenticateCmd(int KeyNo).

    Bur as far as I understand it, it will only send the first Command to the Card, but all the DES Decryption and generating a random number that will be send back,... has still to be done by ME!!

    So finally to my question: Is there a method for the WHOLE Authentication process??

    If not, has anyone written that himself and is willing to post it??



    -Thanks, NFC_Man

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    4

    Re: NFC + DESFire Security

    NFC_Man, I am sorry to note that I do not have a solution to your problem, but I notice that you were able to establish a DESFireConnection to a DESFire Card. I have been unable to do this. How did you detect the card? Could you please send me a code snippet?

    I assume there is some API of which I am not aware, but I cannot figure it out.

    Thanks,
    - Cameron

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    27

    Re: NFC + DESFire Security

    Hi Cameron,

    To detect the card you have to set the target listener as follows:

    Code:
    private DiscoveryManager dm = null;
    
    dm = DiscoveryManager.getInstance();
    try {
    	dm.addTargetListener(this, TargetType.ISO14443_CARD);
        }
    Once you have placed an ISO14443 Card (DESFire, SmartMX,...) on the reader, the program will jump into the TargetDetected() method where you can set up the connection to the card:

    Code:
    import com.nokia.nfc.nxp.desfire.DESFireConnection;
    
    public void targetDetected(TargetProperties[] properties){
    log.append(">> Target detected!\n");
    		
    TargetProperties target = properties[0];
    Class[] classes = target.getConnectionNames();
            
    for (int i=0; i<classes.length; i++) {
    try {
            if (classes[i].equals(Class.forName("com.nokia.nfc.nxp.desfire.DESFireConnection"))) { 
                 String url = target.getUrl(classes[i]);
                        
                 // Open connection to DesFire Card
                 log.append(">> Opening connection\n");
                 private DESFireConnection conn = null;             
                 conn = (DESFireConnection)Connector.open(url);
                       
                 //Now you can communicate with the card!!
                 //example for exchanging data with card
                //byte[] response = conn.exchangeData(msg);
             }
          }
    }
    //catch() {}
    }
    Hope that helps!!

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    4

    Re: NFC + DESFire Security

    NFC_Man,

    Yeah, my code looked pretty much exactly like that and didn't work. I was having real troubles understanding what the problem was. But one of the Nokia guys has responded to one of my other posts, and apparently DESFire doesn't work on the emulator with an external card reader. ( http://discussion.forum.nokia.com/fo...d.php?t=122848 )

    So it wasn't my code after all.

    Thanks for the help,

    Cameron

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    27

    Re: NFC + DESFire Security

    Oh yes, I had the same problem and it took me a while to find out!! If you have a phone use that for testing your code!!

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    6

    Re: NFC + DESFire Security

    Hi,

    I have a couple of problems with authenticating with a new/empty DESFre card from my midlet in 6131 (real device, not emulator).

    step I - I create an application on the card with AP_MASTER_KEY_FOR_FILE_ACESS
    step II - I select the application I've just created
    step III - I try to create a standrd data file with free access rights, but I get a -82 error code.

    I guess this is because there has been no authentication so far. But when creating the application, I can not specify the key.

    I think I should specify a key using the DSEFireSecurity class, but it does not have a create method, it just has a change method. Since I don't have a key yet how do I do it? Is there any other way?

  7. #7
    Registered User
    Join Date
    Feb 2008
    Posts
    6

    Re: NFC + DESFire Security

    Of course, -82 is the int value, in bytes I mean "AE".

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    1

    Question Re: NFC + DESFire Security

    Hi All,

    i am facing problem in the Authentication .

    when i send Authetenticate(0x0A) with keyno 0x00 its giving me 3 or 4 bytes only
    0x0a 0x0 0x7e
    or 0x0a 0x0 0x67 0x0



    any solutions
    waiting for reply......
    Thanks
    Raghu D P

  9. #9
    Registered User
    Join Date
    Aug 2010
    Posts
    1

    Question Re: NFC + DESFire Security

    can any one give me a working code example to read/write over mifare 1KB card?..i m integrating this in c# ...

    i hope someone will response me very soon.

    thanks in advance.

    [DllImport("MifareAPI.dll")]
    public static extern bool USBConnect(ref long devId);

    [DllImport("MifareAPI.dll")]
    public static extern byte MF_GetCardUID(uint dwRspBufSz, byte[] pRspBuf);


    [DllImport("MifareAPI.dll")]
    public static extern Boolean MF_CardOK(ushort wRetCode);

    [DllImport("MifareAPI.dll")]
    public static extern short MF_GetCardStatus();

    [DllImport("MifareAPI.dll")]
    public static extern short DisconnectAll();

    [DllImport("MifareAPI.dll")]
    public static extern short MF_StoreKey(byte[] readerKey, ref byte[] keyBuffer);

    [DllImport("MifareAPI.dll")]
    public static extern ushort MF_WriteCardBlock(byte blockAddress, byte[] readerKey, Boolean highLow, ref byte[] userBuffer);

    [DllImport("MifareAPI.dll")]
    public static extern short MF_WriteCardSec(int readerKey, Boolean dwKeyAB, long buffSize,
    ref byte[] pDataBuff,ref long sectorInformation);
    [DllImport("MifareAPI.dll")]
    public static extern short WriteCfg();

    [DllImport("MifareAPI.dll")]
    public static extern byte MF_ReadCardBlock(byte blockAddress,
    byte[] readerKey, Boolean keyAB,int bufferSize,out byte[] receiveUserBuffer);

    [DllImport("MifareAPI.dll")]
    public static extern byte MF_ReadCardSec(int readerKey, int KeyAB,
    uint respBufferSize,ref char[] pRespectiveBuffer,ref int sectorInformation);

    [DllImport("MifareAPI.dll")]
    public static extern byte SetEEBlock(int blockNumber, ref byte[] pBuf);

    [DllImport("MifareAPI.dll")]
    public static extern byte GetEEBlock(int BlockNumber,out byte[] pBuff);

    [DllImport("MifareAPI.dll")]
    public static extern short rf_GetDevType();
    [DllImport("MifareAPI.dll")]
    public static extern short GetDID();

    [DllImport("MifareAPI.dll")]
    public static extern uint ResetFactoryDflts();

    i m using mifare.dll
    and my device name is AIR ID Writer
    dev Company Name:RFIDeas
    Last edited by rootdhirendra; 2010-08-23 at 11:14. Reason: some additional information

Similar Threads

  1. Nokia 6131 NFC SDK v. 1.1 has been released!
    By Raluca_ in forum Near Field Communication
    Replies: 8
    Last Post: 2008-05-29, 13:54
  2. Oct 29, Nokia NFC developer event - Join to connect, Espoo Finland
    By samuuh in forum Near Field Communication
    Replies: 3
    Last Post: 2007-11-14, 10:31
  3. 3220 NFC Shell communication problem (Error Code: -6)
    By AllenHuang in forum Near Field Communication
    Replies: 1
    Last Post: 2007-09-17, 07:54
  4. NFC Encoder & JCOP Tools
    By ToP Tunniste in forum Near Field Communication
    Replies: 0
    Last Post: 2007-09-11, 08:18
  5. Nokia 6131 NFC SDK 1.0 has been released
    By Nokia Ron in forum Near Field Communication
    Replies: 0
    Last Post: 2007-03-26, 22:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •