Hi Tamás,
My first instinct was that it was wrong.
After a while, I had the same thought you just did.
But then again, after some consideration, I came to my first conclusion.
Here's why.
Assume you have this black box.
You throw it some input and you always get a true/false response. This takes O( n ) where n is the length of the secret.
That sounds safe enough, because like you said, it ensures constant comparison time in all cases.
I don't think this is safe enough, and I will give another example.
Assume now, that, you're somehow able to replicate this box, let's call it white box. (Say for instance, that you're able to set up a machine that has the same hardware and configuration of black box which runs this program managing the secret).
I called this second box "white" on purpose: you are able to reconfigure its secret.
So, you try with password length n=1 and you measure the time it takes if you give it an input with different length.
You measure the time it takes to process a wrong password for this n.
Now you increase n by 1.
You repeat this process until you get the same response time as the black box.
When you have a similar response time, you have guessed the right length of the black box.
Yes we can say it is constant time between runs against the same secret, but the problem is, this time changes depending on the length of the secret.
I know this is all tricky to guess it right, but from the point of view of timing attacks, I guess it makes sense?
So in my second example I changed the question to: instead of taking O ( n ) with n being the length of the secret, I think it's safer to take O ( i ) where i is the length of the input. This shouldn't be a problem, since i is already a given (it's the size of the input!). If and only if i = n, then it will go the normal comparison against the secret, and that should take O ( n ) = O ( i ). Therefore there is no leakage of n nor its contents.
There is also the if/else branching problem and the && false, like I said but I guess that is kind of minimal compared to the problem I outlined before.
Best,
Mario