This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C167CS mystery

Hello all,
This is the deal: 2 identical controllers of type C167CS. The requirement is that one product cannot be used without the other, so I devised a simple authentication protocol:

R(n) = ( (A * R(n-1) + C) mod M)

is computed on both products, where R(n) is an 32 bit integer, and A = 1366, C = 150889, M = 714025 the seed R(n-1) is selected by assigning the clock value to it. The clock value is added or subtracted from the constants A, C and M depending if it is add or not. One product sends the clock value and the selected offset over a CAN bus and the other reconstructs the answer and sends it back. If the answers match - product is authenticated.
I wrote the code about 2 weeks ago, tested it and checked in. But today, the same code did not function anymore. I managed to get it to work, but only after making the following modifications:
* working with constants that limit the range of the intermediate results to 16 bit width.
* remove the modulus operator.

I also encounter problems with comparing two 32 bit integers. I had to compare these numbers in 2 stages, 16 bits each. I admit that I did not thoroughly check the generated assembly.
Can you offer an explanation? How come it worked over the course of several hours and then - not anymore? (for clarity: the product's answers did not agree anymore).
Are all the assumptions of all moderns computing false :-) ?

Parents
  • You're aware that whatever security by obscurity your little protocol might have had is null and void now that you've posted it here, right?

    the seed R(n-1) is selected by assigning the clock value to it. The clock value is added or subtracted from the constants A, C and M depending if it is add or not.

    You're not making terribly much sense there. What do you use that "clock" for: the (inappropriately named) R(n-1), or for fudging the parameters? Or were you actually telling us that you used this same number for both things? If you were, that can't be good.

    One product sends the clock value and the selected offset

    What clock value is that? I.e. counted how, at what granularity?

    Oh, and what offset is that, and why does it need sending?

    How come it worked over the course of several hours and then - not anymore?

    Possibly because your implementation can't handle large values of that "clock" of yours, but your original tests didn't run long enough to reach sufficiently large numbers.

    Since you failed to show any actual source code I'll have to guess: you implicitly expected computations on 16-bit numbers to yield a 32-bit result. Well, sorry, C doesn't work that way.

Reply
  • You're aware that whatever security by obscurity your little protocol might have had is null and void now that you've posted it here, right?

    the seed R(n-1) is selected by assigning the clock value to it. The clock value is added or subtracted from the constants A, C and M depending if it is add or not.

    You're not making terribly much sense there. What do you use that "clock" for: the (inappropriately named) R(n-1), or for fudging the parameters? Or were you actually telling us that you used this same number for both things? If you were, that can't be good.

    One product sends the clock value and the selected offset

    What clock value is that? I.e. counted how, at what granularity?

    Oh, and what offset is that, and why does it need sending?

    How come it worked over the course of several hours and then - not anymore?

    Possibly because your implementation can't handle large values of that "clock" of yours, but your original tests didn't run long enough to reach sufficiently large numbers.

    Since you failed to show any actual source code I'll have to guess: you implicitly expected computations on 16-bit numbers to yield a 32-bit result. Well, sorry, C doesn't work that way.

Children