Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use strcmp to compare passwords.
Add password_equal() which tries to avoid leaking the length of the secret through timing side-channels. Suggested-by: SUSE Security Team <security@suse.de>
- Loading branch information
Showing
4 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#define main _main_disabled_ | ||
#include "../darkhttpd.c" | ||
#undef main | ||
|
||
static void | ||
test(int equal, const char *user_input, const char *secret) | ||
{ | ||
int out = password_equal(user_input, secret); | ||
printf("%s: \"%s\" \"%s\"\n", | ||
(equal == out) ? "PASS" : "FAIL", | ||
user_input, secret); | ||
} | ||
|
||
int | ||
main(void) | ||
{ | ||
test(1, "", ""); | ||
test(1, "a", "a"); | ||
test(1, "abc", "abc"); | ||
|
||
test(0, "a", ""); | ||
test(0, "ab", ""); | ||
test(0, "", "a"); | ||
test(0, "", "ab"); | ||
test(0, "abcd", "abc"); | ||
test(0, "abc", "abcd"); | ||
return 0; | ||
} | ||
|
||
/* vim:set tabstop=4 shiftwidth=4 expandtab tw=78: */ |