PaulS:

There must be. But, it’s unlikely that they will tell you what the algorithm is.

It seems like someone has figured out what algorithm it is using.

```
unsigned long Keeloq::encrypt(unsigned long data)
{
unsigned long x = data;
unsigned long r;
int keyBitNo, index;
unsigned long keyBitVal,bitVal;
for (r = 0; r < 528; r++)
{
keyBitNo = r & 63;
if(keyBitNo < 32)
keyBitVal = bitRead(_keyLow,keyBitNo);
else
keyBitVal = bitRead(_keyHigh, keyBitNo - 32);
index = 1 * bitRead(x,1) + 2 * bitRead(x,9) + 4 * bitRead(x,20) + 8 * bitRead(x,26) + 16 * bitRead(x,31);
bitVal = bitRead(x,0) ^ bitRead(x, 16) ^ bitRead(KeeLoq_NLF,index) ^ keyBitVal;
x = (x>>1) ^ bitVal<<31;
}
return x;
}
```

I think it makes no sense to keep the algorithm secret. Security shouldn’t be purely based on that. Otherwise if someone discovered the algorithm somehow or it was leaked then there would be a huge problem.

It should be like the SSL protocol. Everyone knows how to generate keys and everyone has access to the public keys but you still can’t hack it.

PaulS:

The receiver simply generates a stream of data that is one of the streams of data that the receiver understands. It does this in the same way that MasterCard generates valid credit card numbers. They are not about to tell you how they know that a set of 16 digits is, or is not, a valid credit card number. Nor, I’m sure, are the Keeloq people going to tell you anything.

I am assuming that you meant *‘The ***transmitter** simply generates’. Okay, the transmitter will transmit a certain code and the receiver will receive it. Fine. However, I don’t think the receiver has a way of guessing what the next code will be, otherwise it wouldn’t be secure. There will be millions of possible combinations so really, next time a code is received there’s no way to know if it was the expected one.

PaulS:

Except the receiver knows not to expect to see that same sequence again, until after a number of other sequences have been received. The transmitter knows to send a different sequence each time. The receiver knows what sequence should be next. Anything out of order is rejected.

I do understand that wrong codes are simply ignored. This is why parking your car in a car lot won’t cause your system any trouble, even if the other cars are exactly the same model as yours - because the key does not match and it will never because there are millions of possibilities.