I got a binary file and I'm supposed to crack its password (homework). There was also a function given (a function which is a part of the binary file). That function showed that the input string was compared with the correct password character by character and returned false instantly when a character was wrong (that's not secure way of doing it I guess because it's leaking time and we get an idea of the correct password length as example). But our teacher has added a random timer that returns the result (Correct / Wrong) to make it a little harder for us...
Anyway, I have I already done it successfully with reverse engineering and got the correct password. Now I'm playing with it in the command line:
/usr/bin/time -v ./program_name enter_password
With this command, I get a lot information such as system time, swaps, execution time..But what is most interesting to me is "Voluntary context switches" because the more correct characters of the password I enter, the less "Voluntary context switches" I get!
The more wrong characters I enter, the more "Voluntary context switches" I get.
It took me almost two hours to crack the password just by entering that command, entering characters and observing "Voluntary context switches". Whenever ONE character was correct, the "Voluntary context switches" decreased by one.
My question, what exactly are "Voluntary context switches" and why did they help me cracking the password?