tests: simplify regenerate_credentials.py
tests: simplify regenerate_credentials.py

Reduce repetition via a helper function to generate and dump credentials
to the specified filename.

Yubico/pam-u2f,Yubico/pam-u2f,Yubico/pam-u2f