diff options
author | Colin Watson <cjwatson@debian.org> | 2008-05-17 07:48:57 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2008-05-17 07:48:57 +0000 |
commit | 1f920ffc4c4f933e3c4e8c474460385fea131266 (patch) | |
tree | 7c23ed1becb8b315640229ad8eb18405b532151a | |
parent | 7eb2c79966e70e03a1ecbdf9077d64299241bd3a (diff) |
Check RSA1 keys without the need for a separate blacklist. Thanks to
Simon Tatham for the idea.
-rw-r--r-- | authfile.c | 10 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | ssh-vulnkey.1 | 6 | ||||
-rw-r--r-- | ssh-vulnkey.c | 11 |
4 files changed, 23 insertions, 6 deletions
diff --git a/authfile.c b/authfile.c index 5348a014d..a18509a50 100644 --- a/authfile.c +++ b/authfile.c | |||
@@ -693,6 +693,7 @@ blacklist_filename(const Key *key) | |||
693 | int | 693 | int |
694 | blacklisted_key(const Key *key) | 694 | blacklisted_key(const Key *key) |
695 | { | 695 | { |
696 | Key *public; | ||
696 | char *blacklist_file; | 697 | char *blacklist_file; |
697 | int fd = -1; | 698 | int fd = -1; |
698 | char *dgst_hex = NULL; | 699 | char *dgst_hex = NULL; |
@@ -704,13 +705,17 @@ blacklisted_key(const Key *key) | |||
704 | off_t start, lower, upper; | 705 | off_t start, lower, upper; |
705 | int ret = 0; | 706 | int ret = 0; |
706 | 707 | ||
707 | blacklist_file = blacklist_filename(key); | 708 | public = key_demote(key); |
709 | if (public->type == KEY_RSA1) | ||
710 | public->type = KEY_RSA; | ||
711 | |||
712 | blacklist_file = blacklist_filename(public); | ||
708 | debug("Checking blacklist file %s", blacklist_file); | 713 | debug("Checking blacklist file %s", blacklist_file); |
709 | fd = open(blacklist_file, O_RDONLY); | 714 | fd = open(blacklist_file, O_RDONLY); |
710 | if (fd < 0) | 715 | if (fd < 0) |
711 | goto out; | 716 | goto out; |
712 | 717 | ||
713 | dgst_hex = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX); | 718 | dgst_hex = key_fingerprint(public, SSH_FP_MD5, SSH_FP_HEX); |
714 | /* Remove all colons */ | 719 | /* Remove all colons */ |
715 | dgst_packed = xcalloc(1, strlen(dgst_hex) + 1); | 720 | dgst_packed = xcalloc(1, strlen(dgst_hex) + 1); |
716 | for (i = 0, p = dgst_packed; dgst_hex[i]; i++) | 721 | for (i = 0, p = dgst_packed; dgst_hex[i]; i++) |
@@ -786,5 +791,6 @@ out: | |||
786 | if (fd >= 0) | 791 | if (fd >= 0) |
787 | close(fd); | 792 | close(fd); |
788 | xfree(blacklist_file); | 793 | xfree(blacklist_file); |
794 | key_free(public); | ||
789 | return ret; | 795 | return ret; |
790 | } | 796 | } |
diff --git a/debian/changelog b/debian/changelog index be81951e5..29f80cc8b 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -3,6 +3,8 @@ openssh (1:4.7p1-11) UNRELEASED; urgency=low | |||
3 | * Fix typo in ssh/vulnerable_host_keys message (thanks, Esko Arajärvi). | 3 | * Fix typo in ssh/vulnerable_host_keys message (thanks, Esko Arajärvi). |
4 | * debconf template translations: | 4 | * debconf template translations: |
5 | - Update Finnish (thanks, Esko Arajärvi; closes: #481530). | 5 | - Update Finnish (thanks, Esko Arajärvi; closes: #481530). |
6 | * Check RSA1 keys without the need for a separate blacklist. Thanks to | ||
7 | Simon Tatham for the idea. | ||
6 | 8 | ||
7 | -- Colin Watson <cjwatson@debian.org> Sat, 17 May 2008 08:48:45 +0200 | 9 | -- Colin Watson <cjwatson@debian.org> Sat, 17 May 2008 08:48:45 +0200 |
8 | 10 | ||
diff --git a/ssh-vulnkey.1 b/ssh-vulnkey.1 index 41de104de..73570fcad 100644 --- a/ssh-vulnkey.1 +++ b/ssh-vulnkey.1 | |||
@@ -166,13 +166,15 @@ If present, contains the protocol version 1 RSA identity of the system. | |||
166 | .It Pa /etc/ssh/blacklist. Ns Ar TYPE Ns Pa - Ns Ar LENGTH | 166 | .It Pa /etc/ssh/blacklist. Ns Ar TYPE Ns Pa - Ns Ar LENGTH |
167 | If present, lists the blacklisted keys of type | 167 | If present, lists the blacklisted keys of type |
168 | .Ar TYPE | 168 | .Ar TYPE |
169 | .Pf ( Dq RSA1 , | 169 | .Pf ( Dq RSA |
170 | .Dq RSA , | ||
171 | or | 170 | or |
172 | .Dq DSA ) | 171 | .Dq DSA ) |
173 | and bit length | 172 | and bit length |
174 | .Ar LENGTH . | 173 | .Ar LENGTH . |
175 | The format of this file is described above. | 174 | The format of this file is described above. |
175 | RSA1 keys are converted to RSA before being checked in the blacklist. | ||
176 | Note that the fingerprints of RSA1 keys are computed differently, so you | ||
177 | will not be able to find them in the blacklist by hand. | ||
176 | .El | 178 | .El |
177 | .Sh SEE ALSO | 179 | .Sh SEE ALSO |
178 | .Xr ssh-keygen 1 , | 180 | .Xr ssh-keygen 1 , |
diff --git a/ssh-vulnkey.c b/ssh-vulnkey.c index 3297c431a..f13eb1619 100644 --- a/ssh-vulnkey.c +++ b/ssh-vulnkey.c | |||
@@ -86,21 +86,28 @@ describe_key(const char *msg, const Key *key, const char *comment) | |||
86 | int | 86 | int |
87 | do_key(const Key *key, const char *comment) | 87 | do_key(const Key *key, const char *comment) |
88 | { | 88 | { |
89 | Key *public; | ||
89 | char *blacklist_file; | 90 | char *blacklist_file; |
90 | struct stat st; | 91 | struct stat st; |
91 | int ret = 1; | 92 | int ret = 1; |
92 | 93 | ||
93 | blacklist_file = blacklist_filename(key); | 94 | public = key_demote(key); |
95 | if (public->type == KEY_RSA1) | ||
96 | public->type = KEY_RSA; | ||
97 | |||
98 | blacklist_file = blacklist_filename(public); | ||
94 | if (stat(blacklist_file, &st) < 0) | 99 | if (stat(blacklist_file, &st) < 0) |
95 | describe_key("Unknown (no blacklist information)", | 100 | describe_key("Unknown (no blacklist information)", |
96 | key, comment); | 101 | key, comment); |
97 | else if (blacklisted_key(key)) { | 102 | else if (blacklisted_key(public)) { |
98 | describe_key("COMPROMISED", key, comment); | 103 | describe_key("COMPROMISED", key, comment); |
99 | ret = 0; | 104 | ret = 0; |
100 | } else | 105 | } else |
101 | describe_key("Not blacklisted", key, comment); | 106 | describe_key("Not blacklisted", key, comment); |
102 | xfree(blacklist_file); | 107 | xfree(blacklist_file); |
103 | 108 | ||
109 | key_free(public); | ||
110 | |||
104 | return ret; | 111 | return ret; |
105 | } | 112 | } |
106 | 113 | ||