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
Bookmarks