Skip to content

Commit 7a77c31

Browse files
author
=
committed
added PMK selftest
1 parent 9d6f509 commit 7a77c31

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

hcxpottool.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,24 @@ fclose(fh_potfile);
578578
return;
579579
}
580580
/*===========================================================================*/
581+
static bool selftest(void)
582+
{
583+
static int tstpsklen = 8;
584+
static int tstessidlen = 8;
585+
static const char tstpsk[] = { "12345678" };
586+
static const u8 tstessid[] = { "hcxtools" };
587+
588+
static u8 tstpmk[] =
589+
{
590+
0x8e, 0x65, 0xab, 0xcf, 0x53, 0xeb, 0x04, 0xb9, 0x75, 0x85, 0xb7, 0xcb, 0x2d, 0x26, 0xf5, 0xae,
591+
0xcf, 0x82, 0x92, 0xef, 0x37, 0x66, 0x93, 0xd0, 0x5c, 0x82, 0xce, 0xf5, 0x61, 0xad, 0xb6, 0x8f
592+
};
593+
static u8 calcpmk[32] = { 0 };
594+
595+
if(PKCS5_PBKDF2_HMAC_SHA1(tstpsk, tstpsklen, tstessid, tstessidlen, 4096, PMKLEN, calcpmk) != 1) return false;
596+
if(memcmp(tstpmk, calcpmk, PMKLEN) != 0) return false;
597+
return true;
598+
}
581599
/*===========================================================================*/
582600
static void sortandclean(void)
583601
{
@@ -1352,6 +1370,11 @@ if(globalinit() == false)
13521370
fprintf(stderr, "failed to init lists\n");
13531371
return EXIT_FAILURE;
13541372
}
1373+
if(selftest() == false)
1374+
{
1375+
fprintf(stderr, "selftest failed\n");
1376+
return EXIT_FAILURE;
1377+
}
13551378
if(faultyoutname != NULL)
13561379
{
13571380
if((fh_faulty = fopen(faultyoutname, "a+")) == NULL) fprintf(stdout, "error opening file %s: %s\n", faultyoutname, strerror(errno));

0 commit comments

Comments
 (0)