Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int compareKey() {
- unsigned int leng = strleng(keyInput);
- unsigned int correctLeng = strleng(correctKey);
- int i, randomTime, falseKey = 0;
- unsigned int seed = getpid() + keyInput[0];
- srand(seed); // initialize the random seed
- if (leng != correctLeng)
- return 1;
- for (i = correctLeng-1; i >= 0; i--) {
- if (keyInput[i] != correctKey[i]) {
- usleep(500000); // that delay will stop bruteforce attack
- falseKey = 1;
- }
- }
- randomTime = 500000 * (rand() % 3);
- usleep(randomTime); // take that
- // and this will prevent the attacker to perform a timed attack
- return falseKey;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement