forked from openssh/openssh-portable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FingerprintHash option to control algorithm used for key fingerprints. Default changes from MD5 to SHA256 and format from hex to base64. Feedback and ok naddy@ markus@
- Loading branch information
Showing
28 changed files
with
374 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: auth-rsa.c,v 1.88 2014/07/15 15:54:14 millert Exp $ */ | ||
/* $OpenBSD: auth-rsa.c,v 1.89 2014/12/21 22:27:56 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -236,7 +236,8 @@ rsa_key_allowed_in_file(struct passwd *pw, char *file, | |
"actual %d vs. announced %d.", | ||
file, linenum, BN_num_bits(key->rsa->n), bits); | ||
|
||
fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX); | ||
fp = key_fingerprint(key, options.fingerprint_hash, | ||
SSH_FP_DEFAULT); | ||
debug("matching key found: file %s, line %lu %s %s", | ||
file, linenum, key_type(key), fp); | ||
free(fp); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: digest-libc.c,v 1.3 2014/06/24 01:13:21 djm Exp $ */ | ||
/* $OpenBSD: digest-libc.c,v 1.4 2014/12/21 22:27:56 djm Exp $ */ | ||
/* | ||
* Copyright (c) 2013 Damien Miller <[email protected]> | ||
* Copyright (c) 2014 Markus Friedl. All rights reserved. | ||
|
@@ -126,6 +126,26 @@ ssh_digest_by_alg(int alg) | |
return &(digests[alg]); | ||
} | ||
|
||
int | ||
ssh_digest_alg_by_name(const char *name) | ||
{ | ||
int alg; | ||
|
||
for (alg = 0; alg < SSH_DIGEST_MAX; alg++) { | ||
if (strcasecmp(name, digests[alg].name) == 0) | ||
return digests[alg].id; | ||
} | ||
return -1; | ||
} | ||
|
||
const char * | ||
ssh_digest_alg_name(int alg) | ||
{ | ||
const struct ssh_digest *digest = ssh_digest_by_alg(alg); | ||
|
||
return digest == NULL ? NULL : digest->name; | ||
} | ||
|
||
size_t | ||
ssh_digest_bytes(int alg) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: digest-openssl.c,v 1.4 2014/07/03 03:26:43 djm Exp $ */ | ||
/* $OpenBSD: digest-openssl.c,v 1.5 2014/12/21 22:27:56 djm Exp $ */ | ||
/* | ||
* Copyright (c) 2013 Damien Miller <[email protected]> | ||
* | ||
|
@@ -74,6 +74,26 @@ ssh_digest_by_alg(int alg) | |
return &(digests[alg]); | ||
} | ||
|
||
int | ||
ssh_digest_alg_by_name(const char *name) | ||
{ | ||
int alg; | ||
|
||
for (alg = 0; digests[alg].id != -1; alg++) { | ||
if (strcasecmp(name, digests[alg].name) == 0) | ||
return digests[alg].id; | ||
} | ||
return -1; | ||
} | ||
|
||
const char * | ||
ssh_digest_alg_name(int alg) | ||
{ | ||
const struct ssh_digest *digest = ssh_digest_by_alg(alg); | ||
|
||
return digest == NULL ? NULL : digest->name; | ||
} | ||
|
||
size_t | ||
ssh_digest_bytes(int alg) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: digest.h,v 1.6 2014/07/03 04:36:45 djm Exp $ */ | ||
/* $OpenBSD: digest.h,v 1.7 2014/12/21 22:27:56 djm Exp $ */ | ||
/* | ||
* Copyright (c) 2013 Damien Miller <[email protected]> | ||
* | ||
|
@@ -33,6 +33,12 @@ | |
struct sshbuf; | ||
struct ssh_digest_ctx; | ||
|
||
/* Looks up a digest algorithm by name */ | ||
int ssh_digest_alg_by_name(const char *name); | ||
|
||
/* Returns the algorithm name for a digest identifier */ | ||
const char *ssh_digest_alg_name(int alg); | ||
|
||
/* Returns the algorithm's digest length in bytes or 0 for invalid algorithm */ | ||
size_t ssh_digest_bytes(int alg); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: readconf.c,v 1.223 2014/12/04 02:24:32 djm Exp $ */ | ||
/* $OpenBSD: readconf.c,v 1.224 2014/12/21 22:27:56 djm Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -60,6 +60,7 @@ | |
#include "mac.h" | ||
#include "uidswap.h" | ||
#include "myproposal.h" | ||
#include "digest.h" | ||
|
||
/* Format of the configuration file: | ||
|
@@ -155,6 +156,7 @@ typedef enum { | |
oCanonicalDomains, oCanonicalizeHostname, oCanonicalizeMaxDots, | ||
oCanonicalizeFallbackLocal, oCanonicalizePermittedCNAMEs, | ||
oStreamLocalBindMask, oStreamLocalBindUnlink, oRevokedHostKeys, | ||
oFingerprintHash, | ||
oIgnoredUnknownOption, oDeprecated, oUnsupported | ||
} OpCodes; | ||
|
||
|
@@ -270,6 +272,7 @@ static struct { | |
{ "streamlocalbindmask", oStreamLocalBindMask }, | ||
{ "streamlocalbindunlink", oStreamLocalBindUnlink }, | ||
{ "revokedhostkeys", oRevokedHostKeys }, | ||
{ "fingerprinthash", oFingerprintHash }, | ||
{ "ignoreunknown", oIgnoreUnknown }, | ||
|
||
{ NULL, oBadOption } | ||
|
@@ -1460,6 +1463,18 @@ process_config_line(Options *options, struct passwd *pw, const char *host, | |
charptr = &options->revoked_host_keys; | ||
goto parse_string; | ||
|
||
case oFingerprintHash: | ||
arg = strdelim(&s); | ||
if (!arg || *arg == '\0') | ||
fatal("%.200s line %d: Missing argument.", | ||
filename, linenum); | ||
if ((value = ssh_digest_alg_by_name(arg)) == -1) | ||
fatal("%.200s line %d: Invalid hash algorithm \"%s\".", | ||
filename, linenum, arg); | ||
if (*activep) | ||
options->fingerprint_hash = value; | ||
break; | ||
|
||
case oDeprecated: | ||
debug("%s line %d: Deprecated option \"%s\"", | ||
filename, linenum, keyword); | ||
|
@@ -1637,6 +1652,7 @@ initialize_options(Options * options) | |
options->canonicalize_fallback_local = -1; | ||
options->canonicalize_hostname = -1; | ||
options->revoked_host_keys = NULL; | ||
options->fingerprint_hash = -1; | ||
} | ||
|
||
/* | ||
|
@@ -1814,6 +1830,9 @@ fill_default_options(Options * options) | |
options->canonicalize_fallback_local = 1; | ||
if (options->canonicalize_hostname == -1) | ||
options->canonicalize_hostname = SSH_CANONICALISE_NO; | ||
if (options->fingerprint_hash == -1) | ||
options->fingerprint_hash = SSH_FP_HASH_DEFAULT; | ||
|
||
#define CLEAR_ON_NONE(v) \ | ||
do { \ | ||
if (option_clear_or_none(v)) { \ | ||
|
@@ -2071,6 +2090,8 @@ fmt_intarg(OpCodes code, int val) | |
return fmt_multistate_int(val, multistate_requesttty); | ||
case oCanonicalizeHostname: | ||
return fmt_multistate_int(val, multistate_canonicalizehostname); | ||
case oFingerprintHash: | ||
return ssh_digest_alg_name(val); | ||
case oProtocol: | ||
switch (val) { | ||
case SSH_PROTO_1: | ||
|
@@ -2205,6 +2226,7 @@ dump_client_config(Options *o, const char *host) | |
dump_cfg_fmtint(oControlMaster, o->control_master); | ||
dump_cfg_fmtint(oEnableSSHKeysign, o->enable_ssh_keysign); | ||
dump_cfg_fmtint(oExitOnForwardFailure, o->exit_on_forward_failure); | ||
dump_cfg_fmtint(oFingerprintHash, o->fingerprint_hash); | ||
dump_cfg_fmtint(oForwardAgent, o->forward_agent); | ||
dump_cfg_fmtint(oForwardX11, o->forward_x11); | ||
dump_cfg_fmtint(oForwardX11Trusted, o->forward_x11_trusted); | ||
|
Oops, something went wrong.