OTP data

Tagged: 

  • 22. March 2016 at 9:55
    Hi!

    I've developed an Android app that show how many rides is remaining on Mifare Ultralight card.
    Recently I found a problem: usually to get the counter from OTP I need to count the unset bits (0) to get Remaining rides available.
    Example: 11111111111111000000000000000000 - 18 rides available

    But in some cases counter has different behavior: I have to get the set count of bits (1) to get number of Used rides.
    Example: 11111000000000000000000000000000 - 5 rides used

    How can I know which type of calculation I should use for particular card? (is there some OTP configuration bit on card set?)

    Regards,
    Maratkuls
    + 0  |  - 0

    Re: OTP data

    22. March 2016 at 13:01
    Hi Maratkuls,

    From my point of view it is no difference. If you always count the 1 bits found, you know the zero bits left, Zerobits = 32 – Onebits.

    Kind regards,
    The MIFARE Team

    + 0  |  - 0

    Re: OTP data

    22. March 2016 at 13:15
    Hi,

    There is difference:

    Exmaple 1:
    Zerobits = 32 - 14 = 18 this is fine.

    Example 2:
    Zerobits = 32 - 5 = 27 this is wrong! as all 5 rides out of 5 are already used!!!

    In Example 2 I should get initial rides count (in my case it was 5) so:
    Zerobits = inital count - 5 = 5 - 5 = 0
    But this logic will fail with Example 1 where I had 20 rides:
    Zerobits = inital count - 14 = 20 - 14 = 6 this is wrong!


    That's why I'm asking is there some place where the "behavior" of counter is defined?

    BR, Maratkuls
    + 0  |  - 0

    Re: OTP data

    22. March 2016 at 15:48
    Hi Maratkuls,

    Before you issue the card to the end-user you should set the maximal available rides left. If the user is allowed to get only 5 rides, you initialize the OTP counter with FFFFFFE0 (11…1100000). Of course you can also use 07FFFFFF, this depends on whether you prefer left or right shifting to count zeros or ones.

    Your algorithm have to count the zeros of the OTP to determine if is any rides left. I would read the value and mask out 0x0000000001 and shift in a loop and check if it is zero or not.

    The MIFARE Team

    + 0  |  - 0
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.