/* This function runs the PBKDF2 on the data with a given key. To obtain the PSK from the password, PBKDF2 is run on SSID (data) with password (key).  */
uint8 pbkdf2_sha1(uint8 *key, uint8 key_len, uint8 *data, uint8 data_len, uint8 *digest)
/* This function runs the PBKDF2 on the data with a given key. To obtain the PSK from the password, PBKDF2 is run on SSID (data) with password (key).  */
uint8 pbkdf2_sha1(uint8 *key, uint8 key_len, uint8 *data, uint8 data_len, uint8 *digest)
{
    if ((key_len > 64) || (data_len > 32))
        return 0;
    if (pbkdf2_sha1_f(key, key_len, data, data_len, 4096, 1, digest) == 0) {
        return 0;
    }
    return pbkdf2_sha1_f(key, key_len, data, data_len, 4096, 2, &digest[A_SHA_DIGEST_LEN]);
}