Just compare my solution (PKCS5_PBKDF2_HMAC -> HMAC(EVP_sha1)
$ wlangenpmk -e "hashcat-essid" -p "hashcat!"
essid (networkname)....: hashcat-essid
password...............: hashcat!
plainmasterkey (SHA1)..: 88f43854ae7b1624fc2ab7724859e795130f4843c7535729e819cf92f39535dc
with your code ( (PKCS5_PBKDF2_HMAC -> PKCS5_PBKDF2_HMAC -> HMAC(EVP_sha1):
you run PKCS5_PBKDF2_HMAC twice. That result in a wrong PMK
your PMK = 29033d570e2f52259f03135c935239053c7d0e0c3bb9ab06e97d92e3c3da3e4e
There is absolutely no need to calculate the PSK (by your first function), because it is given:
const char* password = "hashcat!";
as well as the ESSID:
const char* salttext = "hashcat-essid";
Code:
PMK is calculated by:
PKCS5_PBKDF2_HMAC((const char*)psk, psklen, (unsigned char*)essid, essidlen, 4096, EVP_sha1(), 32, pmk)
PMKID is calculated by:
HMAC(EVP_sha1(), pmk, 32, salt, 20, pmkid, NULL);
essid (networkname)....: hashcat-essid
password...............: hashcat!
plainmasterkey (SHA1)..: 88f43854ae7b1624fc2ab7724859e795130f4843c7535729e819cf92f39535dc
with your code ( (PKCS5_PBKDF2_HMAC -> PKCS5_PBKDF2_HMAC -> HMAC(EVP_sha1):
Code:
//Calculate PSK = PBKDF2(Passphrase, SSID, 4096)
PKCS5_PBKDF2_HMAC(pass, (int)strlen(pass), (const unsigned char*)salt,(int)strlen(salt), iterations, EVP_sha1(), outputBytes, digest);
//Calculate PMK = PBKDF2(HMAC−SHA1, PSK, SSID, 4096, 256)
PKCS5_PBKDF2_HMAC((const char*)digest, 32, (const unsigned char*)salt, (int)strlen(salt), iterations, EVP_sha1(), outputBytes, digest);
//Calculate PMKID = HMAC-SHA1-128(PMK,"PMK Name" | MAC_AP | MAC_STA)
HMAC(EVP_sha1(), (const char*)digest, 32, (const unsigned char*)salt_PMKID, (size_t)20, digest, PMKID_len);
/*memcpy(test, (const unsigned char*)salt_PMKID, 20);*/
your PMK = 29033d570e2f52259f03135c935239053c7d0e0c3bb9ab06e97d92e3c3da3e4e
There is absolutely no need to calculate the PSK (by your first function), because it is given:
const char* password = "hashcat!";
as well as the ESSID:
const char* salttext = "hashcat-essid";