test weak keys
This commit is contained in:
@@ -234,6 +234,15 @@ s2k(char *password, const char *salt, char akey[8])
|
||||
free(pw);
|
||||
}
|
||||
|
||||
static void
|
||||
weak_test(int is_weak, const char akey[8])
|
||||
{
|
||||
DES_cblock key;
|
||||
memcpy(&key, akey, sizeof(key));
|
||||
if (DES_is_weak_key(&key) != is_weak)
|
||||
errx(1, "weakness is wrong");
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@@ -552,7 +561,6 @@ main(int argc, char **argv)
|
||||
s2k("", "",
|
||||
"\x01\x01\x01\x01\x01\x01\x01\xf1");
|
||||
|
||||
if (1) {
|
||||
cfb64_test("\x45\xc2\x0b\x01\x40\x08\x13\x8a",
|
||||
"\x9a\xef\xf4\x37\x41\x69\x0b\xd6",
|
||||
"\x5d\x12\x5d\xf5\xae\x1d\xc6\x47\x21\xd3\x16\xba\x45\x0e\x9d\x4c\x00\xfd\xf8\x64\xca\x69\x67",
|
||||
@@ -589,8 +597,27 @@ main(int argc, char **argv)
|
||||
"\xb9\x29\xe6\x78\xdd\x1a\x13\x84",
|
||||
"\x12\x9b\xe5\xb3\xdd\x42\x6f\x45\x86\x97\x25\x87\x05\xee\x7e\x57\x8f\x22\x79\xb3\x22\xa2\x95",
|
||||
"\x38\xef\x49\xbc\xdd\xbb\x6b\x73\xc0\xd7\xa6\x70\xe0\x1b\xde\x8d\xe6\xb4\xc6\x69\xca\x5e\x1e");
|
||||
}
|
||||
|
||||
weak_test(1, "\x01\x01\x01\x01\x01\x01\x01\x01"); /* weak keys */
|
||||
weak_test(1, "\x01\x01\x01\x01\x01\x01\x01\x01");
|
||||
weak_test(1, "\xFE\xFE\xFE\xFE\xFE\xFE\xFE\xFE");
|
||||
weak_test(1, "\x1F\x1F\x1F\x1F\x0E\x0E\x0E\x0E");
|
||||
weak_test(1, "\xE0\xE0\xE0\xE0\xF1\xF1\xF1\xF1");
|
||||
weak_test(1, "\x01\xFE\x01\xFE\x01\xFE\x01\xFE"); /* semi-weak keys */
|
||||
weak_test(1, "\xFE\x01\xFE\x01\xFE\x01\xFE\x01");
|
||||
weak_test(1, "\x1F\xE0\x1F\xE0\x0E\xF1\x0E\xF1");
|
||||
weak_test(1, "\xE0\x1F\xE0\x1F\xF1\x0E\xF1\x0E");
|
||||
weak_test(1, "\x01\xE0\x01\xE0\x01\xF1\x01\xF1");
|
||||
weak_test(1, "\xE0\x01\xE0\x01\xF1\x01\xF1\x01");
|
||||
weak_test(1, "\x1F\xFE\x1F\xFE\x0E\xFE\x0E\xFE");
|
||||
weak_test(1, "\xFE\x1F\xFE\x1F\xFE\x0E\xFE\x0E");
|
||||
weak_test(1, "\x01\x1F\x01\x1F\x01\x0E\x01\x0E");
|
||||
weak_test(1, "\x1F\x01\x1F\x01\x0E\x01\x0E\x01");
|
||||
weak_test(1, "\xE0\xFE\xE0\xFE\xF1\xFE\xF1\xFE");
|
||||
weak_test(1, "\xFE\xE0\xFE\xE0\xFE\xF1\xFE\xF1");
|
||||
|
||||
weak_test(0, "\x01\x01\x01\x01\x01\x01\x01\x02");
|
||||
weak_test(0, "\xFF\xE0\xFE\xE0\xFE\xF1\xFE\xF1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user