mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 10:18:21 -05:00
eapol_test: Add PC/SC reader and PIN command line arguments
The new command line arguments -R<reader> and -P<PIN> can now be used to specify which PC/SC reader (prefix match) and PIN are to be used. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
5a620604f8
commit
e9852462d5
@ -73,6 +73,9 @@ struct eapol_test_data {
|
||||
struct extra_radius_attr *extra_attrs;
|
||||
|
||||
FILE *server_cert_file;
|
||||
|
||||
const char *pcsc_reader;
|
||||
const char *pcsc_pin;
|
||||
};
|
||||
|
||||
static struct eapol_test_data eapol_test;
|
||||
@ -954,7 +957,7 @@ static void wpa_init_conf(struct eapol_test_data *e,
|
||||
}
|
||||
|
||||
|
||||
static int scard_test(void)
|
||||
static int scard_test(struct eapol_test_data *e)
|
||||
{
|
||||
struct scard_data *scard;
|
||||
size_t len;
|
||||
@ -985,10 +988,10 @@ static int scard_test(void)
|
||||
unsigned char aka_ik[IK_LEN];
|
||||
unsigned char aka_ck[CK_LEN];
|
||||
|
||||
scard = scard_init(NULL);
|
||||
scard = scard_init(e->pcsc_reader);
|
||||
if (scard == NULL)
|
||||
return -1;
|
||||
if (scard_set_pin(scard, "1234")) {
|
||||
if (scard_set_pin(scard, e->pcsc_pin)) {
|
||||
wpa_printf(MSG_WARNING, "PIN validation failed");
|
||||
scard_deinit(scard);
|
||||
return -1;
|
||||
@ -1063,7 +1066,7 @@ failed:
|
||||
}
|
||||
|
||||
|
||||
static int scard_get_triplets(int argc, char *argv[])
|
||||
static int scard_get_triplets(struct eapol_test_data *e, int argc, char *argv[])
|
||||
{
|
||||
struct scard_data *scard;
|
||||
size_t len;
|
||||
@ -1085,7 +1088,7 @@ static int scard_get_triplets(int argc, char *argv[])
|
||||
wpa_debug_level = 99;
|
||||
}
|
||||
|
||||
scard = scard_init(NULL);
|
||||
scard = scard_init(e->pcsc_reader);
|
||||
if (scard == NULL) {
|
||||
printf("Failed to open smartcard connection\n");
|
||||
return -1;
|
||||
@ -1143,7 +1146,8 @@ static void usage(void)
|
||||
"[-s<AS secret>]\\\n"
|
||||
" [-r<count>] [-t<timeout>] [-C<Connect-Info>] \\\n"
|
||||
" [-M<client MAC address>] [-o<server cert file] \\\n"
|
||||
" [-N<attr spec>] \\\n"
|
||||
" [-N<attr spec>] [-R<PC/SC reader>] "
|
||||
"[-P<PC/SC PIN>] \\\n"
|
||||
" [-A<client IP>]\n"
|
||||
"eapol_test scard\n"
|
||||
"eapol_test sim <PIN> <num triplets> [debug]\n"
|
||||
@ -1208,12 +1212,13 @@ int main(int argc, char *argv[])
|
||||
os_memset(&eapol_test, 0, sizeof(eapol_test));
|
||||
eapol_test.connect_info = "CONNECT 11Mbps 802.11b";
|
||||
os_memcpy(eapol_test.own_addr, "\x02\x00\x00\x00\x00\x01", ETH_ALEN);
|
||||
eapol_test.pcsc_pin = "1234";
|
||||
|
||||
wpa_debug_level = 0;
|
||||
wpa_debug_show_keys = 1;
|
||||
|
||||
for (;;) {
|
||||
c = getopt(argc, argv, "a:A:c:C:eM:nN:o:p:r:s:St:W");
|
||||
c = getopt(argc, argv, "a:A:c:C:eM:nN:o:p:P:r:R:s:St:W");
|
||||
if (c < 0)
|
||||
break;
|
||||
switch (c) {
|
||||
@ -1254,9 +1259,14 @@ int main(int argc, char *argv[])
|
||||
case 'p':
|
||||
as_port = atoi(optarg);
|
||||
break;
|
||||
case 'P':
|
||||
eapol_test.pcsc_pin = optarg;
|
||||
break;
|
||||
case 'r':
|
||||
eapol_test.eapol_test_num_reauths = atoi(optarg);
|
||||
break;
|
||||
case 'R':
|
||||
eapol_test.pcsc_reader = optarg;
|
||||
case 's':
|
||||
as_secret = optarg;
|
||||
break;
|
||||
@ -1304,11 +1314,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (argc > optind && os_strcmp(argv[optind], "scard") == 0) {
|
||||
return scard_test();
|
||||
return scard_test(&eapol_test);
|
||||
}
|
||||
|
||||
if (argc > optind && os_strcmp(argv[optind], "sim") == 0) {
|
||||
return scard_get_triplets(argc - optind - 1,
|
||||
return scard_get_triplets(&eapol_test, argc - optind - 1,
|
||||
&argv[optind + 1]);
|
||||
}
|
||||
|
||||
@ -1344,6 +1354,11 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (eapol_test.pcsc_reader) {
|
||||
os_free(wpa_s.conf->pcsc_reader);
|
||||
wpa_s.conf->pcsc_reader = os_strdup(eapol_test.pcsc_reader);
|
||||
}
|
||||
|
||||
wpa_init_conf(&eapol_test, &wpa_s, as_addr, as_port, as_secret,
|
||||
cli_addr);
|
||||
wpa_s.ctrl_iface = wpa_supplicant_ctrl_iface_init(&wpa_s);
|
||||
|
Loading…
Reference in New Issue
Block a user