| Like literally the first post issue is completely incorrect, thats one of the issues in reading a post like this in an online thread, literally that user copied part of but not all of the function that is used for RNG. The part they copied uses analog input as one of the sources of entropy, they failed to also include the 6 capacitive touch inputs that are also inputs to the RNG. Those touch inputs literally change every time you press a button and even with atmospheric changes, i.e. it's cloudy out today, your RNG has changed. RNG.stir((uint8_t )analog1, sizeof(analog1), sizeof(analog1) 4); touchread1 = touchRead(TOUCHPIN1); RNG.stir((uint8_t )touchread1, sizeof(touchread1), sizeof(touchread1)); delay((analog1 % 3) + ((touchread1 + touchread2 + touchread3) % 3)); //delay 0 - 6 ms
integrityctr1++; touchread2 = touchRead(TOUCHPIN2);
RNG.stir((uint8_t )touchread2, sizeof(touchread2), sizeof(touchread2)); touchread3 = touchRead(TOUCHPIN3); RNG.stir((uint8_t )touchread3, sizeof(touchread3), sizeof(touchread3)); touchread4 = touchRead(TOUCHPIN4); RNG.stir((uint8_t )touchread4, sizeof(touchread4), sizeof(touchread4)); touchread5 = touchRead(TOUCHPIN5); RNG.stir((uint8_t )touchread5, sizeof(touchread5), sizeof(touchread5));
touchread6 = touchRead(TOUCHPIN6); RNG.stir((uint8_t )touchread6, sizeof(touchread6), sizeof(touchread6)); unsigned int analog2 = analogRead(ANALOGPIN2); RNG.stir((uint8_t )analog2, sizeof(analog2), sizeof(analog2) 4); // Perform regular housekeeping on the random number generator. RNG.loop(); delay((analog2 % 3) + ((touchread6 + touchread5 + touchread4) % 3)); //delay 0 - 6 ms integrityctr2++; if (integrityctr1 != integrityctr2)
{ //Integrity Check
unlocked = false;
CPU_RESTART();
return;
} https://github.com/trustcrypto/libraries/blob/5bd1f8eb15eb04... |
Let me say it again: you're taking an ADC reading (in the range of 0-1023) and accessing it as if it's a memory address.
To make things worse, addresses 0 through 1023 on the Kinetis you're using are the vector table. Take a look at that part of your firmware: it's extremely predictable, and only contains a small number of possible values.