File: ssh2_pick_fingerprint.c

package info (click to toggle)
putty 0.83-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,216 kB
  • sloc: ansic: 148,476; python: 8,466; perl: 1,830; makefile: 128; sh: 117
file content (27 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
}