ssh2_pick_fingerprint.c 803 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Choose an SSH-2 fingerprint type, out of an array of possible ones.
  3. */
  4. #include "defs.h"
  5. #include "misc.h"
  6. #include "ssh.h"
  7. FingerprintType ssh2_pick_fingerprint(
  8. char **fingerprints, FingerprintType preferred_type)
  9. {
  10. /*
  11. * Keys are either SSH-2, in which case we have all fingerprint
  12. * types, or SSH-1, in which case we have only MD5. So we return
  13. * the default type if we can, or MD5 if that's all we have; no
  14. * need for a fully general preference-list system.
  15. */
  16. FingerprintType fptype = fingerprints[preferred_type] ?
  17. preferred_type : SSH_FPTYPE_MD5;
  18. assert(fingerprints[fptype]);
  19. return fptype;
  20. }
  21. FingerprintType ssh2_pick_default_fingerprint(char **fingerprints)
  22. {
  23. return ssh2_pick_fingerprint(fingerprints, SSH_FPTYPE_DEFAULT);
  24. }