diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-01-15 09:40:00 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-01-15 21:39:14 +1100 |
commit | 1129dcfc5a3e508635004bcc05a3574cb7687167 (patch) | |
tree | 7cd4eaa0c3a62f5b20f1f347a5081a4d160260b2 /dns.c | |
parent | e4ebf5586452bf512da662ac277aaf6ecf0efe7c (diff) |
upstream commit
sync ssh-keysign, ssh-keygen and some dependencies to the
new buffer/key API; mostly mechanical, ok markus@
Diffstat (limited to 'dns.c')
-rw-r--r-- | dns.c | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dns.c,v 1.32 2014/12/21 22:27:56 djm Exp $ */ | 1 | /* $OpenBSD: dns.c,v 1.33 2015/01/15 09:40:00 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2003 Wesley Griffin. All rights reserved. | 4 | * Copyright (c) 2003 Wesley Griffin. All rights reserved. |
@@ -38,7 +38,8 @@ | |||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | 39 | ||
40 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
41 | #include "key.h" | 41 | #include "sshkey.h" |
42 | #include "ssherr.h" | ||
42 | #include "dns.h" | 43 | #include "dns.h" |
43 | #include "log.h" | 44 | #include "log.h" |
44 | #include "digest.h" | 45 | #include "digest.h" |
@@ -78,9 +79,9 @@ dns_result_totext(unsigned int res) | |||
78 | */ | 79 | */ |
79 | static int | 80 | static int |
80 | dns_read_key(u_int8_t *algorithm, u_int8_t *digest_type, | 81 | dns_read_key(u_int8_t *algorithm, u_int8_t *digest_type, |
81 | u_char **digest, u_int *digest_len, Key *key) | 82 | u_char **digest, size_t *digest_len, struct sshkey *key) |
82 | { | 83 | { |
83 | int success = 0; | 84 | int r, success = 0; |
84 | int fp_alg = -1; | 85 | int fp_alg = -1; |
85 | 86 | ||
86 | switch (key->type) { | 87 | switch (key->type) { |
@@ -121,9 +122,10 @@ dns_read_key(u_int8_t *algorithm, u_int8_t *digest_type, | |||
121 | } | 122 | } |
122 | 123 | ||
123 | if (*algorithm && *digest_type) { | 124 | if (*algorithm && *digest_type) { |
124 | *digest = key_fingerprint_raw(key, fp_alg, digest_len); | 125 | if ((r = sshkey_fingerprint_raw(key, fp_alg, digest, |
125 | if (*digest == NULL) | 126 | digest_len)) != 0) |
126 | fatal("dns_read_key: null from key_fingerprint_raw()"); | 127 | fatal("%s: sshkey_fingerprint_raw: %s", __func__, |
128 | ssh_err(r)); | ||
127 | success = 1; | 129 | success = 1; |
128 | } else { | 130 | } else { |
129 | *digest = NULL; | 131 | *digest = NULL; |
@@ -139,7 +141,7 @@ dns_read_key(u_int8_t *algorithm, u_int8_t *digest_type, | |||
139 | */ | 141 | */ |
140 | static int | 142 | static int |
141 | dns_read_rdata(u_int8_t *algorithm, u_int8_t *digest_type, | 143 | dns_read_rdata(u_int8_t *algorithm, u_int8_t *digest_type, |
142 | u_char **digest, u_int *digest_len, u_char *rdata, int rdata_len) | 144 | u_char **digest, size_t *digest_len, u_char *rdata, int rdata_len) |
143 | { | 145 | { |
144 | int success = 0; | 146 | int success = 0; |
145 | 147 | ||
@@ -200,7 +202,7 @@ is_numeric_hostname(const char *hostname) | |||
200 | */ | 202 | */ |
201 | int | 203 | int |
202 | verify_host_key_dns(const char *hostname, struct sockaddr *address, | 204 | verify_host_key_dns(const char *hostname, struct sockaddr *address, |
203 | Key *hostkey, int *flags) | 205 | struct sshkey *hostkey, int *flags) |
204 | { | 206 | { |
205 | u_int counter; | 207 | u_int counter; |
206 | int result; | 208 | int result; |
@@ -209,12 +211,12 @@ verify_host_key_dns(const char *hostname, struct sockaddr *address, | |||
209 | u_int8_t hostkey_algorithm; | 211 | u_int8_t hostkey_algorithm; |
210 | u_int8_t hostkey_digest_type = SSHFP_HASH_RESERVED; | 212 | u_int8_t hostkey_digest_type = SSHFP_HASH_RESERVED; |
211 | u_char *hostkey_digest; | 213 | u_char *hostkey_digest; |
212 | u_int hostkey_digest_len; | 214 | size_t hostkey_digest_len; |
213 | 215 | ||
214 | u_int8_t dnskey_algorithm; | 216 | u_int8_t dnskey_algorithm; |
215 | u_int8_t dnskey_digest_type; | 217 | u_int8_t dnskey_digest_type; |
216 | u_char *dnskey_digest; | 218 | u_char *dnskey_digest; |
217 | u_int dnskey_digest_len; | 219 | size_t dnskey_digest_len; |
218 | 220 | ||
219 | *flags = 0; | 221 | *flags = 0; |
220 | 222 | ||
@@ -310,13 +312,13 @@ verify_host_key_dns(const char *hostname, struct sockaddr *address, | |||
310 | * Export the fingerprint of a key as a DNS resource record | 312 | * Export the fingerprint of a key as a DNS resource record |
311 | */ | 313 | */ |
312 | int | 314 | int |
313 | export_dns_rr(const char *hostname, Key *key, FILE *f, int generic) | 315 | export_dns_rr(const char *hostname, struct sshkey *key, FILE *f, int generic) |
314 | { | 316 | { |
315 | u_int8_t rdata_pubkey_algorithm = 0; | 317 | u_int8_t rdata_pubkey_algorithm = 0; |
316 | u_int8_t rdata_digest_type = SSHFP_HASH_RESERVED; | 318 | u_int8_t rdata_digest_type = SSHFP_HASH_RESERVED; |
317 | u_int8_t dtype; | 319 | u_int8_t dtype; |
318 | u_char *rdata_digest; | 320 | u_char *rdata_digest; |
319 | u_int i, rdata_digest_len; | 321 | size_t i, rdata_digest_len; |
320 | int success = 0; | 322 | int success = 0; |
321 | 323 | ||
322 | for (dtype = SSHFP_HASH_SHA1; dtype < SSHFP_HASH_MAX; dtype++) { | 324 | for (dtype = SSHFP_HASH_SHA1; dtype < SSHFP_HASH_MAX; dtype++) { |
@@ -324,7 +326,7 @@ export_dns_rr(const char *hostname, Key *key, FILE *f, int generic) | |||
324 | if (dns_read_key(&rdata_pubkey_algorithm, &rdata_digest_type, | 326 | if (dns_read_key(&rdata_pubkey_algorithm, &rdata_digest_type, |
325 | &rdata_digest, &rdata_digest_len, key)) { | 327 | &rdata_digest, &rdata_digest_len, key)) { |
326 | if (generic) { | 328 | if (generic) { |
327 | fprintf(f, "%s IN TYPE%d \\# %d %02x %02x ", | 329 | fprintf(f, "%s IN TYPE%d \\# %zu %02x %02x ", |
328 | hostname, DNS_RDATATYPE_SSHFP, | 330 | hostname, DNS_RDATATYPE_SSHFP, |
329 | 2 + rdata_digest_len, | 331 | 2 + rdata_digest_len, |
330 | rdata_pubkey_algorithm, rdata_digest_type); | 332 | rdata_pubkey_algorithm, rdata_digest_type); |