Yubico Forum
https://forum.yubico.com/

Yubikey Simulator! HELP - need low level CRC-routine[SOLVED]
https://forum.yubico.com/viewtopic.php?f=16&t=69
Page 2 of 2

Author:  fortean [ Sun Aug 30, 2009 9:41 pm ]
Post subject:  Re: Yubikey Simulator! HELP - need low level CRC-routine[SOLVED]

JakobE wrote:
1st complement (= bit flip) is thw way to go.


Thanks, Jakob - in fact, you made me a happy man, as my software seems to work properly already then :). Now, I hope to find the time this week to finish the first prototype of Yubidrone, will keep you posted.

Author:  yuvalr [ Sun Aug 15, 2010 5:08 pm ]
Post subject:  Re: Yubikey Simulator! HELP - need low level CRC-routine[SOLVED]

hi folks :)

i'm trying to accomplish a similar Yubikey simulator, only implemented in Java.

unfortunately, i'm still stuck in the crc calculation. in Alex's php project it's written just the same, but for some reason it's not working for me - when i take the generated block (16 bytes including the crc), in order to validate the generated block i call:
Code:
new com.yubico.base.Token(block);

that runs it through its own crc check, but then i get
Quote:
java.lang.IllegalArgumentException: CRC failure

i can't figure out why is that, especially that it worked for Alex?

my CRC generation code:
Code:
   private static int calculateCrc(byte[] b) {
        int crc = 0x5af0;

        for (int i = 0; i < 14; i++) {
          crc ^= b[i] & 0xFF;
          for (int j = 0; j < 8; j++){
             int n = crc & 1;
             crc >>= 1;
             if (n != 0) {
               crc ^= 0x8408;
             }
          }
        }
        return crc;
   }

i'm aware of the difference between java and other languages in the implementation of unsigned bytes (there are no unsigned types in Java). but given that all the operations are bitwise, i don't think it should matter, should it? because negative numbers are just specific representations of the same bits..

i will publish the whole project once it's ready, but in the meantime i can appreciate your kind help ;)

many thanks,
Yuval

Author:  yuvalr [ Wed Aug 18, 2010 10:58 am ]
Post subject:  Re: Yubikey Simulator! HELP - need low level CRC-routine[SOLVED]

problem solved, it seems that the original crc calculation (with 0xffff as start value) was ok but i didn't use a ~ for the crc 1-complement, which caused the error.

i will publish the project soon. thanks anyway

Yuval

Author:  wkossen [ Wed Oct 06, 2010 8:32 am ]
Post subject:  Re: Yubikey Simulator! HELP - need low level CRC-routine[SOLVED]

Hi,

The original link you posted sais deprecated and takes me to a new version. That does not work for the source. Could you tell me (us?) where to get the source php?

And how's that java version coming along? That could be helpful to run on mobile platform as midlet...

Author:  yuvalr [ Mon Oct 18, 2010 11:46 am ]
Post subject:  Re: Yubikey Simulator! HELP - need low level CRC-routine[SOLVED]

hi guys

the java-based Yubikeymulator 1.0 is located at
https://code.google.com/p/yubikeymulator/

enjoy!
Yuval

Page 2 of 2 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/