1 /* $OpenBSD: authfile.c,v 1.87 2010/11/29 18:57:04 markus Exp $ */
3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6 * This file contains functions for reading and writing identity files, and
7 * for reading the passphrase from the user.
9 * As far as I am concerned, the code I have written for this software
10 * can be used freely for any purpose. Any derived versions of this
11 * software must be clearly marked as such, and if the derived work is
12 * incompatible with the protocol description in the RFC file, it must be
13 * called by a name other than "ssh" or "Secure Shell".
16 * Copyright (c) 2000 Markus Friedl. All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include <sys/types.h>
43 #include <sys/param.h>
46 #include <openssl/err.h>
47 #include <openssl/evp.h>
48 #include <openssl/pem.h>
50 /* compatibility with old or broken OpenSSL versions */
51 #include "openbsd-compat/openssl-compat.h"
71 #include "pathnames.h"
73 /* Version identification string for SSH v1 identity files. */
74 static const char authfile_id_string[] =
75 "SSH PRIVATE KEY FILE FORMAT 1.1\n";
78 * Serialises the authentication (private) key to a blob, encrypting it with
79 * passphrase. The identification of the blob (lowest 64 bits of n) will
80 * precede the key to provide identification of the key without needing a
84 key_private_rsa1_to_blob(Key *key, Buffer *blob, const char *passphrase,
87 Buffer buffer, encrypted;
90 CipherContext ciphercontext;
95 * If the passphrase is empty, use SSH_CIPHER_NONE to ease converting
96 * to another cipher; otherwise use SSH_AUTHFILE_CIPHER.
98 cipher_num = (strcmp(passphrase, "") == 0) ?
99 SSH_CIPHER_NONE : SSH_AUTHFILE_CIPHER;
100 if ((cipher = cipher_by_number(cipher_num)) == NULL)
101 fatal("save_private_key_rsa: bad cipher");
103 /* This buffer is used to built the secret part of the private key. */
104 buffer_init(&buffer);
106 /* Put checkbytes for checking passphrase validity. */
109 buf[1] = (rnd >> 8) & 0xff;
112 buffer_append(&buffer, buf, 4);
115 * Store the private key (n and e will not be stored because they
116 * will be stored in plain text, and storing them also in encrypted
117 * format would just give known plaintext).
119 buffer_put_bignum(&buffer, key->rsa->d);
120 buffer_put_bignum(&buffer, key->rsa->iqmp);
121 buffer_put_bignum(&buffer, key->rsa->q); /* reverse from SSL p */
122 buffer_put_bignum(&buffer, key->rsa->p); /* reverse from SSL q */
124 /* Pad the part to be encrypted until its size is a multiple of 8. */
125 while (buffer_len(&buffer) % 8 != 0)
126 buffer_put_char(&buffer, 0);
128 /* This buffer will be used to contain the data in the file. */
129 buffer_init(&encrypted);
131 /* First store keyfile id string. */
132 for (i = 0; authfile_id_string[i]; i++)
133 buffer_put_char(&encrypted, authfile_id_string[i]);
134 buffer_put_char(&encrypted, 0);
136 /* Store cipher type. */
137 buffer_put_char(&encrypted, cipher_num);
138 buffer_put_int(&encrypted, 0); /* For future extension */
140 /* Store public key. This will be in plain text. */
141 buffer_put_int(&encrypted, BN_num_bits(key->rsa->n));
142 buffer_put_bignum(&encrypted, key->rsa->n);
143 buffer_put_bignum(&encrypted, key->rsa->e);
144 buffer_put_cstring(&encrypted, comment);
146 /* Allocate space for the private part of the key in the buffer. */
147 cp = buffer_append_space(&encrypted, buffer_len(&buffer));
149 cipher_set_key_string(&ciphercontext, cipher, passphrase,
151 cipher_crypt(&ciphercontext, cp,
152 buffer_ptr(&buffer), buffer_len(&buffer));
153 cipher_cleanup(&ciphercontext);
154 memset(&ciphercontext, 0, sizeof(ciphercontext));
156 /* Destroy temporary data. */
157 memset(buf, 0, sizeof(buf));
158 buffer_free(&buffer);
160 buffer_append(blob, buffer_ptr(&encrypted), buffer_len(&encrypted));
161 buffer_free(&encrypted);
166 /* convert SSH v2 key in OpenSSL PEM format */
168 key_private_pem_to_blob(Key *key, Buffer *blob, const char *_passphrase,
172 int blen, len = strlen(_passphrase);
173 u_char *passphrase = (len > 0) ? (u_char *)_passphrase : NULL;
174 #if (OPENSSL_VERSION_NUMBER < 0x00907000L)
175 const EVP_CIPHER *cipher = (len > 0) ? EVP_des_ede3_cbc() : NULL;
177 const EVP_CIPHER *cipher = (len > 0) ? EVP_aes_128_cbc() : NULL;
182 if (len > 0 && len <= 4) {
183 error("passphrase too short: have %d bytes, need > 4", len);
186 if ((bio = BIO_new(BIO_s_mem())) == NULL) {
187 error("%s: BIO_new failed", __func__);
192 success = PEM_write_bio_DSAPrivateKey(bio, key->dsa,
193 cipher, passphrase, len, NULL, NULL);
195 #ifdef OPENSSL_HAS_ECC
197 success = PEM_write_bio_ECPrivateKey(bio, key->ecdsa,
198 cipher, passphrase, len, NULL, NULL);
202 success = PEM_write_bio_RSAPrivateKey(bio, key->rsa,
203 cipher, passphrase, len, NULL, NULL);
207 if ((blen = BIO_get_mem_data(bio, &bptr)) <= 0)
210 buffer_append(blob, bptr, blen);
216 /* Save a key blob to a file */
218 key_save_private_blob(Buffer *keybuf, const char *filename)
222 if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) {
223 error("open %s failed: %s.", filename, strerror(errno));
226 if (atomicio(vwrite, fd, buffer_ptr(keybuf),
227 buffer_len(keybuf)) != buffer_len(keybuf)) {
228 error("write to key file %s failed: %s", filename,
238 /* Serialise "key" to buffer "blob" */
240 key_private_to_blob(Key *key, Buffer *blob, const char *passphrase,
245 return key_private_rsa1_to_blob(key, blob, passphrase, comment);
249 return key_private_pem_to_blob(key, blob, passphrase, comment);
251 error("%s: cannot save key type %d", __func__, key->type);
257 key_save_private(Key *key, const char *filename, const char *passphrase,
263 buffer_init(&keyblob);
264 if (!key_private_to_blob(key, &keyblob, passphrase, comment))
266 if (!key_save_private_blob(&keyblob, filename))
270 buffer_free(&keyblob);
275 * Parse the public, unencrypted portion of a RSA1 key.
278 key_parse_public_rsa1(Buffer *blob, char **commentp)
282 /* Check that it is at least big enough to contain the ID string. */
283 if (buffer_len(blob) < sizeof(authfile_id_string)) {
284 debug3("Truncated RSA1 identifier");
289 * Make sure it begins with the id string. Consume the id string
292 if (memcmp(buffer_ptr(blob), authfile_id_string,
293 sizeof(authfile_id_string)) != 0) {
294 debug3("Incorrect RSA1 identifier");
297 buffer_consume(blob, sizeof(authfile_id_string));
299 /* Skip cipher type and reserved data. */
300 (void) buffer_get_char(blob); /* cipher type */
301 (void) buffer_get_int(blob); /* reserved */
303 /* Read the public key from the buffer. */
304 (void) buffer_get_int(blob);
305 pub = key_new(KEY_RSA1);
306 buffer_get_bignum(blob, pub->rsa->n);
307 buffer_get_bignum(blob, pub->rsa->e);
309 *commentp = buffer_get_string(blob, NULL);
310 /* The encrypted private part is not parsed by this function. */
316 /* Load the contents of a key file into a buffer */
318 key_load_file(int fd, const char *filename, Buffer *blob)
324 if (fstat(fd, &st) < 0) {
325 error("%s: fstat of key file %.200s%sfailed: %.100s", __func__,
326 filename == NULL ? "" : filename,
327 filename == NULL ? "" : " ",
332 if (st.st_size > 1*1024*1024) {
333 error("%s: key file %.200s%stoo large", __func__,
334 filename == NULL ? "" : filename,
335 filename == NULL ? "" : " ");
339 len = (size_t)st.st_size; /* truncated */
342 cp = buffer_append_space(blob, len);
344 if (atomicio(read, fd, cp, len) != len) {
345 debug("%s: read from key file %.200s%sfailed: %.100s", __func__,
346 filename == NULL ? "" : filename,
347 filename == NULL ? "" : " ",
357 * Loads the public part of the ssh v1 key file. Returns NULL if an error was
358 * encountered (the file does not exist or is not readable), and the key
362 key_load_public_rsa1(int fd, const char *filename, char **commentp)
367 buffer_init(&buffer);
368 if (!key_load_file(fd, filename, &buffer)) {
369 buffer_free(&buffer);
373 pub = key_parse_public_rsa1(&buffer, commentp);
375 debug3("Could not load \"%s\" as a RSA1 public key", filename);
376 buffer_free(&buffer);
380 /* load public key from private-key file, works only for SSH v1 */
382 key_load_public_type(int type, const char *filename, char **commentp)
387 if (type == KEY_RSA1) {
388 fd = open(filename, O_RDONLY);
391 pub = key_load_public_rsa1(fd, filename, commentp);
399 key_parse_private_rsa1(Buffer *blob, const char *passphrase, char **commentp)
401 int check1, check2, cipher_type;
404 CipherContext ciphercontext;
408 /* Check that it is at least big enough to contain the ID string. */
409 if (buffer_len(blob) < sizeof(authfile_id_string)) {
410 debug3("Truncated RSA1 identifier");
415 * Make sure it begins with the id string. Consume the id string
418 if (memcmp(buffer_ptr(blob), authfile_id_string,
419 sizeof(authfile_id_string)) != 0) {
420 debug3("Incorrect RSA1 identifier");
423 buffer_consume(blob, sizeof(authfile_id_string));
425 /* Read cipher type. */
426 cipher_type = buffer_get_char(blob);
427 (void) buffer_get_int(blob); /* Reserved data. */
429 /* Read the public key from the buffer. */
430 (void) buffer_get_int(blob);
431 prv = key_new_private(KEY_RSA1);
433 buffer_get_bignum(blob, prv->rsa->n);
434 buffer_get_bignum(blob, prv->rsa->e);
436 *commentp = buffer_get_string(blob, NULL);
438 (void)buffer_get_string_ptr(blob, NULL);
440 /* Check that it is a supported cipher. */
441 cipher = cipher_by_number(cipher_type);
442 if (cipher == NULL) {
443 debug("Unsupported RSA1 cipher %d", cipher_type);
446 /* Initialize space for decrypted data. */
447 buffer_init(&decrypted);
448 cp = buffer_append_space(&decrypted, buffer_len(blob));
450 /* Rest of the buffer is encrypted. Decrypt it using the passphrase. */
451 cipher_set_key_string(&ciphercontext, cipher, passphrase,
453 cipher_crypt(&ciphercontext, cp,
454 buffer_ptr(blob), buffer_len(blob));
455 cipher_cleanup(&ciphercontext);
456 memset(&ciphercontext, 0, sizeof(ciphercontext));
459 check1 = buffer_get_char(&decrypted);
460 check2 = buffer_get_char(&decrypted);
461 if (check1 != buffer_get_char(&decrypted) ||
462 check2 != buffer_get_char(&decrypted)) {
463 if (strcmp(passphrase, "") != 0)
464 debug("Bad passphrase supplied for RSA1 key");
465 /* Bad passphrase. */
466 buffer_free(&decrypted);
469 /* Read the rest of the private key. */
470 buffer_get_bignum(&decrypted, prv->rsa->d);
471 buffer_get_bignum(&decrypted, prv->rsa->iqmp); /* u */
472 /* in SSL and SSH v1 p and q are exchanged */
473 buffer_get_bignum(&decrypted, prv->rsa->q); /* p */
474 buffer_get_bignum(&decrypted, prv->rsa->p); /* q */
476 /* calculate p-1 and q-1 */
477 rsa_generate_additional_parameters(prv->rsa);
479 buffer_free(&decrypted);
481 /* enable blinding */
482 if (RSA_blinding_on(prv->rsa, NULL) != 1) {
483 error("%s: RSA_blinding_on failed", __func__);
496 key_parse_private_pem(Buffer *blob, int type, const char *passphrase,
501 char *name = "<no key>";
504 if ((bio = BIO_new_mem_buf(buffer_ptr(blob),
505 buffer_len(blob))) == NULL) {
506 error("%s: BIO_new_mem_buf failed", __func__);
510 pk = PEM_read_bio_PrivateKey(bio, NULL, NULL, (char *)passphrase);
513 debug("%s: PEM_read_PrivateKey failed", __func__);
514 (void)ERR_get_error();
515 } else if (pk->type == EVP_PKEY_RSA &&
516 (type == KEY_UNSPEC||type==KEY_RSA)) {
517 prv = key_new(KEY_UNSPEC);
518 prv->rsa = EVP_PKEY_get1_RSA(pk);
520 name = "rsa w/o comment";
522 RSA_print_fp(stderr, prv->rsa, 8);
524 if (RSA_blinding_on(prv->rsa, NULL) != 1) {
525 error("%s: RSA_blinding_on failed", __func__);
529 } else if (pk->type == EVP_PKEY_DSA &&
530 (type == KEY_UNSPEC||type==KEY_DSA)) {
531 prv = key_new(KEY_UNSPEC);
532 prv->dsa = EVP_PKEY_get1_DSA(pk);
534 name = "dsa w/o comment";
536 DSA_print_fp(stderr, prv->dsa, 8);
538 #ifdef OPENSSL_HAS_ECC
539 } else if (pk->type == EVP_PKEY_EC &&
540 (type == KEY_UNSPEC||type==KEY_ECDSA)) {
541 prv = key_new(KEY_UNSPEC);
542 prv->ecdsa = EVP_PKEY_get1_EC_KEY(pk);
543 prv->type = KEY_ECDSA;
544 if ((prv->ecdsa_nid = key_ecdsa_key_to_nid(prv->ecdsa)) == -1 ||
545 key_curve_nid_to_name(prv->ecdsa_nid) == NULL ||
546 key_ec_validate_public(EC_KEY_get0_group(prv->ecdsa),
547 EC_KEY_get0_public_key(prv->ecdsa)) != 0 ||
548 key_ec_validate_private(prv->ecdsa) != 0) {
549 error("%s: bad ECDSA key", __func__);
553 name = "ecdsa w/o comment";
555 if (prv != NULL && prv->ecdsa != NULL)
556 key_dump_ec_key(prv->ecdsa);
558 #endif /* OPENSSL_HAS_ECC */
560 error("%s: PEM_read_PrivateKey: mismatch or "
561 "unknown EVP_PKEY save_type %d", __func__, pk->save_type);
565 if (prv != NULL && commentp)
566 *commentp = xstrdup(name);
567 debug("read PEM private key done: type %s",
568 prv ? key_type(prv) : "<unknown>");
573 key_load_private_pem(int fd, int type, const char *passphrase,
579 buffer_init(&buffer);
580 if (!key_load_file(fd, NULL, &buffer)) {
581 buffer_free(&buffer);
584 prv = key_parse_private_pem(&buffer, type, passphrase, commentp);
585 buffer_free(&buffer);
590 key_perm_ok(int fd, const char *filename)
594 if (fstat(fd, &st) < 0)
597 * if a key owned by the user is accessed, then we check the
598 * permissions of the file. if the key owned by a different user,
599 * then we don't care.
602 if (check_ntsec(filename))
604 if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
605 error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
606 error("@ WARNING: UNPROTECTED PRIVATE KEY FILE! @");
607 error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
608 error("Permissions 0%3.3o for '%s' are too open.",
609 (u_int)st.st_mode & 0777, filename);
610 error("It is recommended that your private key files are NOT accessible by others.");
611 error("This private key will be ignored.");
618 key_parse_private_type(Buffer *blob, int type, const char *passphrase,
623 return key_parse_private_rsa1(blob, passphrase, commentp);
628 return key_parse_private_pem(blob, type, passphrase, commentp);
636 key_load_private_type(int type, const char *filename, const char *passphrase,
637 char **commentp, int *perm_ok)
643 fd = open(filename, O_RDONLY);
645 debug("could not open key file '%s': %s", filename,
651 if (!key_perm_ok(fd, filename)) {
654 error("bad permissions: ignore key: %s", filename);
661 buffer_init(&buffer);
662 if (!key_load_file(fd, filename, &buffer)) {
663 buffer_free(&buffer);
668 ret = key_parse_private_type(&buffer, type, passphrase, commentp);
669 buffer_free(&buffer);
674 key_load_private(const char *filename, const char *passphrase,
678 Buffer buffer, pubcopy;
681 fd = open(filename, O_RDONLY);
683 debug("could not open key file '%s': %s", filename,
687 if (!key_perm_ok(fd, filename)) {
688 error("bad permissions: ignore key: %s", filename);
693 buffer_init(&buffer);
694 if (!key_load_file(fd, filename, &buffer)) {
695 buffer_free(&buffer);
701 buffer_init(&pubcopy);
702 buffer_append(&pubcopy, buffer_ptr(&buffer), buffer_len(&buffer));
703 /* it's a SSH v1 key if the public key part is readable */
704 pub = key_parse_public_rsa1(&pubcopy, commentp);
705 buffer_free(&pubcopy);
707 prv = key_parse_private_type(&buffer, KEY_UNSPEC,
709 /* use the filename as a comment for PEM */
711 *commentp = xstrdup(filename);
714 /* key_parse_public_rsa1() has already loaded the comment */
715 prv = key_parse_private_type(&buffer, KEY_RSA1, passphrase,
718 buffer_free(&buffer);
723 key_try_load_public(Key *k, const char *filename, char **commentp)
726 char line[SSH_MAX_PUBKEY_BYTES];
730 f = fopen(filename, "r");
732 while (read_keyfile_line(f, filename, line, sizeof(line),
741 /* Skip leading whitespace. */
742 for (; *cp && (*cp == ' ' || *cp == '\t'); cp++)
745 if (key_read(k, &cp) == 1) {
747 *commentp=xstrdup(filename);
758 /* load public key from ssh v1 private or any pubkey file */
760 key_load_public(const char *filename, char **commentp)
763 char file[MAXPATHLEN];
765 /* try rsa1 private key */
766 pub = key_load_public_type(KEY_RSA1, filename, commentp);
770 /* try rsa1 public key */
771 pub = key_new(KEY_RSA1);
772 if (key_try_load_public(pub, filename, commentp) == 1)
776 /* try ssh2 public key */
777 pub = key_new(KEY_UNSPEC);
778 if (key_try_load_public(pub, filename, commentp) == 1)
780 if ((strlcpy(file, filename, sizeof file) < sizeof(file)) &&
781 (strlcat(file, ".pub", sizeof file) < sizeof(file)) &&
782 (key_try_load_public(pub, file, commentp) == 1))
789 blacklist_filename(const Key *key)
793 xasprintf(&name, "%s.%s-%u",
794 _PATH_BLACKLIST, key_type(key), key_size(key));
798 /* Scan a blacklist of known-vulnerable keys. */
800 blacklisted_key(Key *key)
802 char *blacklist_file;
804 char *dgst_hex = NULL;
805 char *dgst_packed = NULL, *p;
810 off_t start, lower, upper;
813 blacklist_file = blacklist_filename(key);
814 debug("Checking blacklist file %s", blacklist_file);
815 fd = open(blacklist_file, O_RDONLY);
819 dgst_hex = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
820 /* Remove all colons */
821 dgst_packed = xcalloc(1, strlen(dgst_hex) + 1);
822 for (i = 0, p = dgst_packed; dgst_hex[i]; i++)
823 if (dgst_hex[i] != ':')
825 /* Only compare least-significant 80 bits (to keep the blacklist
828 line_len = strlen(dgst_packed + 12);
832 /* Skip leading comments */
838 r = atomicio(read, fd, buf, 256);
844 newline = memchr(buf, '\n', 256);
847 start += newline + 1 - buf;
848 if (lseek(fd, start, SEEK_SET) < 0)
852 /* Initialise binary search record numbers */
853 if (fstat(fd, &st) < 0)
856 upper = (st.st_size - start) / (line_len + 1);
858 while (lower != upper) {
863 cur = lower + (upper - lower) / 2;
865 /* Read this line and compare to digest; this is
866 * overflow-safe since cur < max(off_t) / (line_len + 1) */
867 if (lseek(fd, start + cur * (line_len + 1), SEEK_SET) < 0)
869 if (atomicio(read, fd, buf, line_len) != line_len)
871 cmp = memcmp(buf, dgst_packed + 12, line_len);
876 } else if (cmp > 0) {
881 debug("Found %s in blacklist", dgst_hex);
894 xfree(blacklist_file);
898 /* Load the certificate associated with the named private key */
900 key_load_cert(const char *filename)
905 pub = key_new(KEY_UNSPEC);
906 xasprintf(&file, "%s-cert.pub", filename);
907 if (key_try_load_public(pub, file, NULL) == 1) {
916 /* Load private key and certificate */
918 key_load_private_cert(int type, const char *filename, const char *passphrase,
929 error("%s: unsupported key type", __func__);
933 if ((key = key_load_private_type(type, filename,
934 passphrase, NULL, perm_ok)) == NULL)
937 if ((pub = key_load_cert(filename)) == NULL) {
942 /* Make sure the private key matches the certificate */
943 if (key_equal_public(key, pub) == 0) {
944 error("%s: certificate does not match private key %s",
946 } else if (key_to_certified(key, key_cert_is_legacy(pub)) != 0) {
947 error("%s: key_to_certified failed", __func__);
949 key_cert_copy(pub, key);
960 * Returns 1 if the specified "key" is listed in the file "filename",
961 * 0 if the key is not listed or -1 on error.
962 * If strict_type is set then the key type must match exactly,
963 * otherwise a comparison that ignores certficiate data is performed.
966 key_in_file(Key *key, const char *filename, int strict_type)
969 char line[SSH_MAX_PUBKEY_BYTES];
974 int (*key_compare)(const Key *, const Key *) = strict_type ?
975 key_equal : key_equal_public;
977 if ((f = fopen(filename, "r")) == NULL) {
978 if (errno == ENOENT) {
979 debug("%s: keyfile \"%s\" missing", __func__, filename);
982 error("%s: could not open keyfile \"%s\": %s", __func__,
983 filename, strerror(errno));
988 while (read_keyfile_line(f, filename, line, sizeof(line),
992 /* Skip leading whitespace. */
993 for (; *cp && (*cp == ' ' || *cp == '\t'); cp++)
996 /* Skip comments and empty lines */
1004 pub = key_new(KEY_UNSPEC);
1005 if (key_read(pub, &cp) != 1) {
1009 if (key_compare(key, pub)) {