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,45 +561,63 @@ 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",
|
||||
"\xff\x99\x06\xd8\xe9\xbc\xae\x7e\xde\x49\x7b\x34\x5d\xa0\x74\x61\x9b\x6f\x70\x38\x40\x40\xba");
|
||||
cfb64_test("\xdc\xe9\x51\xc4\x0b\xad\x85\xa8",
|
||||
"\xf5\x56\x6c\xef\x42\xed\x9f\xa8",
|
||||
"\x7d\xe5\xeb\x04\x5c\xaf\x8c\x5b\xf4\x88\xba\x4a\x99\x6a\x3a\x79\xc0\x88\x01\x05\xac\x98\x3c",
|
||||
"\x53\x87\x11\xc4\xa6\xf3\x1e\x67\x56\xfc\x8c\x63\xf0\x2e\xd9\x0e\x4a\x86\x8e\x5b\xa7\xde\xcf");
|
||||
cfb64_test("\x25\xf7\xa7\x0e\x85\x4f\x5b\xb6",
|
||||
"\x83\xae\x73\x03\xea\xeb\x82\x05",
|
||||
"\x1b\x80\x23\xdc\x61\x23\xa7\xde\x80\xf6\xec\xb1\xc1\x6d\x3e\x59\x1f\x76\x6d\xdf\xfa\x42\xc7",
|
||||
"\xe2\xf7\x8d\x2f\x86\xce\x1f\xfc\xdb\x82\xb9\xb5\x9c\xa9\xf4\x9c\x2b\x3f\x34\x6c\x83\xf7\x7e");
|
||||
cfb64_test("\xab\xd5\xd3\x68\xf1\x2c\x0e\x0d",
|
||||
"\x8a\xea\xe8\xc0\xad\xb9\x51\x83",
|
||||
"\x3d\xcb\x7d\xcf\x57\xa6\xf6\x16\x4f\x34\xb6\x5f\xc2\xa9\xf0\xec\x90\xc5\x43\xa0\x19\xfc\x3f",
|
||||
"\xe9\x2c\x22\x20\xd4\x27\x90\x89\x40\x08\x4a\x23\x4d\x41\x05\x67\xe1\xde\xf5\x0b\x8b\x96\xb1");
|
||||
cfb64_test("\x92\x38\xd3\xfd\x61\x83\x92\x0e",
|
||||
"\x25\xb6\x34\x51\x6d\x6a\x35\xa2",
|
||||
"\x98\x55\xab\x2a\xa2\x9e\xcf\xf4\x92\xdf\xb4\xc6\xc1\x34\x55\xf6\x13\x85\x4c\x50\xdc\x82\x1e",
|
||||
"\x87\x96\x47\xa6\xcd\xff\xda\xd2\xad\x88\xaa\x25\xbd\xcd\x72\x61\x37\x14\x42\x14\xc7\x4b\x7f");
|
||||
cfb64_test("\xf4\xcb\x97\xad\xef\x7f\x80\xb0",
|
||||
"\xfc\xa0\x7d\xb6\x75\xb8\x48\xea",
|
||||
"\xc2\x1e\x16\x2b\xb7\xcf\xc6\xa0\x4b\x76\x75\x61\x49\x66\x0d\xce\xd2\x12\xf2\x98\x07\x2f\xac",
|
||||
"\xe2\x20\xbf\x29\x5b\x34\x20\x2a\x2e\x99\xa5\x50\x97\x1b\x4b\x18\xb4\xd6\x87\x35\x7b\x5f\x43");
|
||||
cfb64_test("\x3b\x1c\x15\xec\xb9\x5e\xe0\xda",
|
||||
"\x7d\x94\x23\x76\x96\x72\x62\xf4",
|
||||
"\x5d\x83\xdb\x76\x52\x46\xa7\x84\x0a\x71\x2c\x09\x40\xbd\x3d\x75\x73\x28\x0b\x22\x07\x6f\x8a",
|
||||
"\xf1\x01\x8f\xe2\x32\x35\xe6\x06\xcf\xbb\xe4\x15\x9e\x4e\xf0\xe8\x2e\xcd\xac\xbf\xa6\xc2\xec");
|
||||
cfb64_test("\xc2\xcd\x76\x79\x7f\x51\xce\x86",
|
||||
"\x38\xcf\x55\x7d\x0c\xd5\x35\xfe",
|
||||
"\xc7\xe5\xe8\x1d\x19\x09\x9f\xd5\xdb\x89\x26\xc1\xf1\xc1\x18\x50\xcf\x8b\xf2\xe1\x87\xeb\xe6",
|
||||
"\xd4\x5d\xca\x30\xb9\x41\xfa\x36\x83\xfc\x40\x2d\xd2\xe8\x94\x38\x49\xc8\xa3\x35\xb7\x5d\x9c");
|
||||
cfb64_test("\x67\xfd\xc4\x31\x45\x40\xf7\xea",
|
||||
"\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");
|
||||
}
|
||||
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",
|
||||
"\xff\x99\x06\xd8\xe9\xbc\xae\x7e\xde\x49\x7b\x34\x5d\xa0\x74\x61\x9b\x6f\x70\x38\x40\x40\xba");
|
||||
cfb64_test("\xdc\xe9\x51\xc4\x0b\xad\x85\xa8",
|
||||
"\xf5\x56\x6c\xef\x42\xed\x9f\xa8",
|
||||
"\x7d\xe5\xeb\x04\x5c\xaf\x8c\x5b\xf4\x88\xba\x4a\x99\x6a\x3a\x79\xc0\x88\x01\x05\xac\x98\x3c",
|
||||
"\x53\x87\x11\xc4\xa6\xf3\x1e\x67\x56\xfc\x8c\x63\xf0\x2e\xd9\x0e\x4a\x86\x8e\x5b\xa7\xde\xcf");
|
||||
cfb64_test("\x25\xf7\xa7\x0e\x85\x4f\x5b\xb6",
|
||||
"\x83\xae\x73\x03\xea\xeb\x82\x05",
|
||||
"\x1b\x80\x23\xdc\x61\x23\xa7\xde\x80\xf6\xec\xb1\xc1\x6d\x3e\x59\x1f\x76\x6d\xdf\xfa\x42\xc7",
|
||||
"\xe2\xf7\x8d\x2f\x86\xce\x1f\xfc\xdb\x82\xb9\xb5\x9c\xa9\xf4\x9c\x2b\x3f\x34\x6c\x83\xf7\x7e");
|
||||
cfb64_test("\xab\xd5\xd3\x68\xf1\x2c\x0e\x0d",
|
||||
"\x8a\xea\xe8\xc0\xad\xb9\x51\x83",
|
||||
"\x3d\xcb\x7d\xcf\x57\xa6\xf6\x16\x4f\x34\xb6\x5f\xc2\xa9\xf0\xec\x90\xc5\x43\xa0\x19\xfc\x3f",
|
||||
"\xe9\x2c\x22\x20\xd4\x27\x90\x89\x40\x08\x4a\x23\x4d\x41\x05\x67\xe1\xde\xf5\x0b\x8b\x96\xb1");
|
||||
cfb64_test("\x92\x38\xd3\xfd\x61\x83\x92\x0e",
|
||||
"\x25\xb6\x34\x51\x6d\x6a\x35\xa2",
|
||||
"\x98\x55\xab\x2a\xa2\x9e\xcf\xf4\x92\xdf\xb4\xc6\xc1\x34\x55\xf6\x13\x85\x4c\x50\xdc\x82\x1e",
|
||||
"\x87\x96\x47\xa6\xcd\xff\xda\xd2\xad\x88\xaa\x25\xbd\xcd\x72\x61\x37\x14\x42\x14\xc7\x4b\x7f");
|
||||
cfb64_test("\xf4\xcb\x97\xad\xef\x7f\x80\xb0",
|
||||
"\xfc\xa0\x7d\xb6\x75\xb8\x48\xea",
|
||||
"\xc2\x1e\x16\x2b\xb7\xcf\xc6\xa0\x4b\x76\x75\x61\x49\x66\x0d\xce\xd2\x12\xf2\x98\x07\x2f\xac",
|
||||
"\xe2\x20\xbf\x29\x5b\x34\x20\x2a\x2e\x99\xa5\x50\x97\x1b\x4b\x18\xb4\xd6\x87\x35\x7b\x5f\x43");
|
||||
cfb64_test("\x3b\x1c\x15\xec\xb9\x5e\xe0\xda",
|
||||
"\x7d\x94\x23\x76\x96\x72\x62\xf4",
|
||||
"\x5d\x83\xdb\x76\x52\x46\xa7\x84\x0a\x71\x2c\x09\x40\xbd\x3d\x75\x73\x28\x0b\x22\x07\x6f\x8a",
|
||||
"\xf1\x01\x8f\xe2\x32\x35\xe6\x06\xcf\xbb\xe4\x15\x9e\x4e\xf0\xe8\x2e\xcd\xac\xbf\xa6\xc2\xec");
|
||||
cfb64_test("\xc2\xcd\x76\x79\x7f\x51\xce\x86",
|
||||
"\x38\xcf\x55\x7d\x0c\xd5\x35\xfe",
|
||||
"\xc7\xe5\xe8\x1d\x19\x09\x9f\xd5\xdb\x89\x26\xc1\xf1\xc1\x18\x50\xcf\x8b\xf2\xe1\x87\xeb\xe6",
|
||||
"\xd4\x5d\xca\x30\xb9\x41\xfa\x36\x83\xfc\x40\x2d\xd2\xe8\x94\x38\x49\xc8\xa3\x35\xb7\x5d\x9c");
|
||||
cfb64_test("\x67\xfd\xc4\x31\x45\x40\xf7\xea",
|
||||
"\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