Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ssh2_pick_fingerprint.c')
-rw-r--r--utils/ssh2_pick_fingerprint.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/utils/ssh2_pick_fingerprint.c b/utils/ssh2_pick_fingerprint.c
new file mode 100644
index 00000000..f81b2f1d
--- /dev/null
+++ b/utils/ssh2_pick_fingerprint.c
@@ -0,0 +1,27 @@
+/*
+ * Choose an SSH-2 fingerprint type, out of an array of possible ones.
+ */
+
+#include "defs.h"
+#include "misc.h"
+#include "ssh.h"
+
+FingerprintType ssh2_pick_fingerprint(
+ char **fingerprints, FingerprintType preferred_type)
+{
+ /*
+ * Keys are either SSH-2, in which case we have all fingerprint
+ * types, or SSH-1, in which case we have only MD5. So we return
+ * the default type if we can, or MD5 if that's all we have; no
+ * need for a fully general preference-list system.
+ */
+ FingerprintType fptype = fingerprints[preferred_type] ?
+ preferred_type : SSH_FPTYPE_MD5;
+ assert(fingerprints[fptype]);
+ return fptype;
+}
+
+FingerprintType ssh2_pick_default_fingerprint(char **fingerprints)
+{
+ return ssh2_pick_fingerprint(fingerprints, SSH_FPTYPE_DEFAULT);
+}