Add constant time memcmp and use it for comparing keys.

There is perhaps no problem now, but it is a good practise to use
constant time for key comaprison to avoid possible side channel
issues.
This commit is contained in:
Milan Broz
2022-04-27 23:05:02 +02:00
parent 4f44bb40b7
commit 2bf0f537f6
12 changed files with 65 additions and 5 deletions

View File

@@ -78,7 +78,7 @@ static int PBKDF2_digest_verify(struct crypt_device *cd,
mkDigestIterations, 0, 0) < 0) {
r = -EINVAL;
} else {
if (memcmp(checkHashBuf, mkDigest, len) == 0)
if (crypt_backend_memeq(checkHashBuf, mkDigest, len) == 0)
r = 0;
}
out: