diff --git a/agent/agent.h b/agent/agent.h --- a/agent/agent.h +++ b/agent/agent.h @@ -116,6 +116,9 @@ /* File name with a patternfile or NULL if not enabled. */ const char *check_passphrase_pattern; + /* Path to a external passphrase checker (NULL to disable). */ + const char *passphrase_quality_checker; + /* If not 0 the user is asked to change his passphrase after these number of days. */ unsigned int max_passphrase_days; diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -39,6 +39,7 @@ #include #include "../common/sysutils.h" #include "../common/i18n.h" +#include "../common/exectool.h" #ifdef _POSIX_OPEN_MAX #define MAX_OPEN_FDS _POSIX_OPEN_MAX @@ -779,6 +780,24 @@ int length; const char *s; + if (opt.passphrase_quality_checker) + { + char *output; + long percent; + + if (gnupg_exec_tool (opt.passphrase_quality_checker, NULL, + pw, &output, NULL)) + return 0; + + percent = strtol (output, NULL, 10); + if (percent < 0) + percent = 0; + if (percent > 100) + percent = 100; + + return percent; + } + if (goodlength < 1) return 0; diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -110,6 +110,7 @@ oMinPassphraseLen, oMinPassphraseNonalpha, oCheckPassphrasePattern, + oPassphraseChecker, oMaxPassphraseDays, oEnablePassphraseHistory, oEnableExtendedKeyFormat, @@ -220,6 +221,7 @@ ARGPARSE_s_s (oCheckPassphrasePattern, "check-passphrase-pattern", "@"), ARGPARSE_s_u (oMaxPassphraseDays, "max-passphrase-days", "@"), ARGPARSE_s_n (oEnablePassphraseHistory, "enable-passphrase-history", "@"), + ARGPARSE_s_s (oPassphraseChecker, "passphrase-checker", "@"), ARGPARSE_s_n (oIgnoreCacheForSigning, "ignore-cache-for-signing", /* */ N_("do not use the PIN cache when signing")), @@ -807,6 +809,7 @@ opt.min_passphrase_len = MIN_PASSPHRASE_LEN; opt.min_passphrase_nonalpha = MIN_PASSPHRASE_NONALPHA; opt.check_passphrase_pattern = NULL; + opt.passphrase_quality_checker = NULL; opt.max_passphrase_days = MAX_PASSPHRASE_DAYS; opt.enable_passphrase_history = 0; opt.enable_extended_key_format = 0; @@ -875,6 +878,9 @@ case oCheckPassphrasePattern: opt.check_passphrase_pattern = pargs->r.ret_str; break; + case oPassphraseChecker: + opt.passphrase_quality_checker = pargs->r.ret_str; + break; case oMaxPassphraseDays: opt.max_passphrase_days = pargs->r.ret_ulong; break;