Thank Richard.
A bit cryptic that C but will try to understand what is going on!
Ioannis
Thank Richard.
A bit cryptic that C but will try to understand what is going on!
Ioannis
I think this is pretty close for decrypt , but don't ask me how it works or why it loops 528 times
Code:x var long r var long keyBitVal var long bitVal var long key var byte[8] ;key is long + long = 64 bits you need to input this somehow index var word KeeLoq_NLF const $3A5C742E decrypt: ; input to decrypt is in var x -> output is in var x while r<528 keyBitNo = (15-r) & 63 keyBitVal = key.0[keyBitNo] index = 1 * x0.[1] + 2 * x.0[9] + 4 * x.0[20] + 8 * x.0[26] + 16 * x.0[31] bitVal = x0.[0] ^ x.0[16] ^ KeeLoq_NLF.0[index] ^ keyBitVal x = (x>>1) ^ bitVal<<31; r=r+1 wend return
a clever person could knock up some code to do 32 bit shift left , right and a 32 bit xor then the whole thing could be done without pbpl at allx = (x>>1) ^ bitVal<<31;
Last edited by richard; - 11th November 2015 at 08:37. Reason: still can't type
Thanks Richard for the effort on this.
I'll try to do the same on the encryption part which is what I am interested in.
About PBPL, sure I will try to do this in PBP since the code is inteded to run on a low end PIC.
Thanks again,
Ioannis
Last edited by Ioannis; - 11th November 2015 at 08:40.
I feel there is something missing here , the code is meant to be rolling encryption . so something needs to be saved for the next call doesn't it ?
The general idea from the limited data I could find is this.
You have your secret keys (8 bytes) that both the encrypter and decrypter know.
Then you have also 4 bytes of data (32 bits) that will be encoded byt the encoder (either hardware or software).
The result will be placed (after the crazy 512 shifts and rotatons) at the same registers of the 4 data bytes. They call it CSR3:CSR0 registers in the data sheet and ANs.
Regarding the decryption I am very close, almost working. But the Encoder is a bit harder to accomplish, mainly because resources are limited on a 12Fxxx chips.
Thanks,
Ioannis
Bookmarks