summaryrefslogtreecommitdiff
path: root/authfile.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-04-30 23:10:43 +0000
committerDamien Miller <djm@mindrot.org>2017-05-01 09:37:40 +1000
commit56912dea6ef63dae4eb1194e5d88973a7c6c5740 (patch)
treec0425585449d257a90a42efce5f602f7ce16779f /authfile.c
parentd4084cd230f7319056559b00db8b99296dad49d5 (diff)
upstream commit
unifdef WITH_SSH1 ok markus@ Upstream-ID: 9716e62a883ef8826c57f4d33b4a81a9cc7755c7
Diffstat (limited to 'authfile.c')
-rw-r--r--authfile.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/authfile.c b/authfile.c
index 0869e5d0d..d28ae0d38 100644
--- a/authfile.c
+++ b/authfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: authfile.c,v 1.123 2017/03/26 00:18:52 deraadt Exp $ */ 1/* $OpenBSD: authfile.c,v 1.124 2017/04/30 23:10:43 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved.
4 * 4 *
@@ -147,35 +147,6 @@ sshkey_load_file(int fd, struct sshbuf *blob)
147 return r; 147 return r;
148} 148}
149 149
150#ifdef WITH_SSH1
151/*
152 * Loads the public part of the ssh v1 key file. Returns NULL if an error was
153 * encountered (the file does not exist or is not readable), and the key
154 * otherwise.
155 */
156static int
157sshkey_load_public_rsa1(int fd, struct sshkey **keyp, char **commentp)
158{
159 struct sshbuf *b = NULL;
160 int r;
161
162 if (keyp != NULL)
163 *keyp = NULL;
164 if (commentp != NULL)
165 *commentp = NULL;
166
167 if ((b = sshbuf_new()) == NULL)
168 return SSH_ERR_ALLOC_FAIL;
169 if ((r = sshkey_load_file(fd, b)) != 0)
170 goto out;
171 if ((r = sshkey_parse_public_rsa1_fileblob(b, keyp, commentp)) != 0)
172 goto out;
173 r = 0;
174 out:
175 sshbuf_free(b);
176 return r;
177}
178#endif /* WITH_SSH1 */
179 150
180/* XXX remove error() calls from here? */ 151/* XXX remove error() calls from here? */
181int 152int
@@ -362,21 +333,7 @@ sshkey_load_public(const char *filename, struct sshkey **keyp, char **commentp)
362 333
363 if ((fd = open(filename, O_RDONLY)) < 0) 334 if ((fd = open(filename, O_RDONLY)) < 0)
364 goto skip; 335 goto skip;
365#ifdef WITH_SSH1
366 /* try rsa1 private key */
367 r = sshkey_load_public_rsa1(fd, keyp, commentp);
368 close(fd);
369 switch (r) {
370 case SSH_ERR_INTERNAL_ERROR:
371 case SSH_ERR_ALLOC_FAIL:
372 case SSH_ERR_INVALID_ARGUMENT:
373 case SSH_ERR_SYSTEM_ERROR:
374 case 0:
375 return r;
376 }
377#else /* WITH_SSH1 */
378 close(fd); 336 close(fd);
379#endif /* WITH_SSH1 */
380 337
381 /* try ssh2 public key */ 338 /* try ssh2 public key */
382 if ((pub = sshkey_new(KEY_UNSPEC)) == NULL) 339 if ((pub = sshkey_new(KEY_UNSPEC)) == NULL)
@@ -388,17 +345,6 @@ sshkey_load_public(const char *filename, struct sshkey **keyp, char **commentp)
388 } 345 }
389 sshkey_free(pub); 346 sshkey_free(pub);
390 347
391#ifdef WITH_SSH1
392 /* try rsa1 public key */
393 if ((pub = sshkey_new(KEY_RSA1)) == NULL)
394 return SSH_ERR_ALLOC_FAIL;
395 if ((r = sshkey_try_load_public(pub, filename, commentp)) == 0) {
396 if (keyp != NULL)
397 *keyp = pub;
398 return 0;
399 }
400 sshkey_free(pub);
401#endif /* WITH_SSH1 */
402 348
403 skip: 349 skip:
404 /* try .pub suffix */ 350 /* try .pub suffix */