passphrase_entry.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef PASSPHRASE_ENTRY_H_
  2. #define PASSPHRASE_ENTRY_H_
  3. /* How should we get the passphrase? */
  4. enum passphrase_entry {
  5. PASSPHRASE_UNSET,
  6. PASSPHRASE_TTY_STDIN,
  7. PASSPHRASE_STDIN_ONCE,
  8. PASSPHRASE_TTY_ONCE,
  9. PASSPHRASE_ENV,
  10. PASSPHRASE_FILE,
  11. };
  12. /**
  13. * passphrase_entry_parse(arg, entry_method_p, entry_arg_p):
  14. * Parse "METHOD:ARG" from ${arg} into an ${*entry_method_p}:${*entry_arg_p}.
  15. */
  16. int passphrase_entry_parse(const char *, enum passphrase_entry *,
  17. const char **);
  18. /**
  19. * passphrase_entry_readpass(passwd, entry_method, entry_arg, prompt,
  20. * confirmprompt, once):
  21. * Use ${entry_method} to read a passphrase and return it as a malloced
  22. * NUL-terminated string via ${passwd}. If ${entry_method} is
  23. * PASSPHRASE_TTY_STDIN and ${once} is zero, ask for the passphrase twice;
  24. * otherwise ask for it once. If reading from a terminal, use ${prompt} for
  25. * the first prompt, and ${confirmprompt} for the second prompt (if
  26. * applicable); otherwise do not print any prompts.
  27. */
  28. int passphrase_entry_readpass(char **, enum passphrase_entry, const char *,
  29. const char *, const char *, int);
  30. #endif /* !PASSPHRASE_ENTRY_H_ */