参考资料:
http://en.wikipedia.org/wiki/KeeLoq
http://cryptolib.com/ciphers/keeloq/
测试程序:
#include <stdio.h>
#include <stdlib.h>typedef unsigned long u32;
typedef unsigned long long u64;
/*\
* Corrected KeeLoq Encryption and Decryption functions by Ruptor.
* Use at your own risk! This source is not copyrighted.
* Encoder encrypts an all-0 block, decoder decrypts it.
* KeeLoq cipher encrypts 32-bit blocks with 64-bit keys.
* Key is XORed with a 32-bit IV incremented on each use.
* See http://www.keeloq.boom.ru/decryption.pdf for more details.
* KeeLoq algorithm itself is not patented.
\*/
#define KeeLoq_N