Annotation of src/usr.bin/ssh/auth2.c, Revision 1.33
1.1 markus 1: /*
2: * Copyright (c) 2000 Markus Friedl. All rights reserved.
3: *
4: * Redistribution and use in source and binary forms, with or without
5: * modification, are permitted provided that the following conditions
6: * are met:
7: * 1. Redistributions of source code must retain the above copyright
8: * notice, this list of conditions and the following disclaimer.
9: * 2. Redistributions in binary form must reproduce the above copyright
10: * notice, this list of conditions and the following disclaimer in the
11: * documentation and/or other materials provided with the distribution.
12: *
13: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: */
1.14 deraadt 24:
1.1 markus 25: #include "includes.h"
1.33 ! markus 26: RCSID("$OpenBSD: auth2.c,v 1.32 2001/01/21 19:05:44 markus Exp $");
1.1 markus 27:
28: #include <openssl/evp.h>
29:
1.32 markus 30: #include "ssh2.h"
1.1 markus 31: #include "xmalloc.h"
32: #include "rsa.h"
33: #include "pty.h"
34: #include "packet.h"
35: #include "buffer.h"
1.32 markus 36: #include "log.h"
1.1 markus 37: #include "servconf.h"
38: #include "compat.h"
39: #include "channels.h"
40: #include "bufaux.h"
41: #include "auth.h"
42: #include "session.h"
43: #include "dispatch.h"
44: #include "auth.h"
45: #include "key.h"
1.32 markus 46: #include "cipher.h"
47: #include "kex.h"
1.29 markus 48: #include "pathnames.h"
1.1 markus 49: #include "uidswap.h"
1.10 markus 50: #include "auth-options.h"
1.1 markus 51:
52: /* import */
53: extern ServerOptions options;
1.23 markus 54: extern u_char *session_id2;
1.1 markus 55: extern int session_id2_len;
56:
1.18 markus 57: static Authctxt *x_authctxt = NULL;
58: static int one = 1;
59:
60: typedef struct Authmethod Authmethod;
61: struct Authmethod {
62: char *name;
63: int (*userauth)(Authctxt *authctxt);
64: int *enabled;
65: };
66:
1.1 markus 67: /* protocol */
68:
1.15 markus 69: void input_service_request(int type, int plen, void *ctxt);
70: void input_userauth_request(int type, int plen, void *ctxt);
71: void protocol_error(int type, int plen, void *ctxt);
1.1 markus 72:
73: /* helper */
1.18 markus 74: Authmethod *authmethod_lookup(const char *name);
75: struct passwd *pwcopy(struct passwd *pw);
1.21 markus 76: int user_key_allowed(struct passwd *pw, Key *key);
1.18 markus 77: char *authmethods_get(void);
1.1 markus 78:
1.18 markus 79: /* auth */
1.25 markus 80: void userauth_banner(void);
1.18 markus 81: int userauth_none(Authctxt *authctxt);
82: int userauth_passwd(Authctxt *authctxt);
83: int userauth_pubkey(Authctxt *authctxt);
84: int userauth_kbdint(Authctxt *authctxt);
85:
86: Authmethod authmethods[] = {
87: {"none",
88: userauth_none,
89: &one},
90: {"publickey",
91: userauth_pubkey,
1.21 markus 92: &options.pubkey_authentication},
1.18 markus 93: {"keyboard-interactive",
94: userauth_kbdint,
95: &options.kbd_interactive_authentication},
96: {"password",
97: userauth_passwd,
98: &options.password_authentication},
99: {NULL, NULL, NULL}
1.1 markus 100: };
101:
102: /*
1.18 markus 103: * loop until authctxt->success == TRUE
1.1 markus 104: */
105:
106: void
107: do_authentication2()
108: {
1.28 markus 109: Authctxt *authctxt = authctxt_new();
110:
1.18 markus 111: x_authctxt = authctxt; /*XXX*/
112:
1.26 markus 113: #ifdef AFS
114: /* If machine has AFS, set process authentication group. */
115: if (k_hasafs()) {
116: k_setpag();
117: k_unlog();
118: }
1.5 djm 119: #endif
1.1 markus 120: dispatch_init(&protocol_error);
121: dispatch_set(SSH2_MSG_SERVICE_REQUEST, &input_service_request);
1.18 markus 122: dispatch_run(DISPATCH_BLOCK, &authctxt->success, authctxt);
1.28 markus 123: do_authenticated2(authctxt);
1.1 markus 124: }
125:
126: void
1.15 markus 127: protocol_error(int type, int plen, void *ctxt)
1.1 markus 128: {
129: log("auth: protocol error: type %d plen %d", type, plen);
130: packet_start(SSH2_MSG_UNIMPLEMENTED);
131: packet_put_int(0);
132: packet_send();
133: packet_write_wait();
134: }
135:
136: void
1.15 markus 137: input_service_request(int type, int plen, void *ctxt)
1.1 markus 138: {
1.18 markus 139: Authctxt *authctxt = ctxt;
1.23 markus 140: u_int len;
1.1 markus 141: int accept = 0;
142: char *service = packet_get_string(&len);
143: packet_done();
144:
1.18 markus 145: if (authctxt == NULL)
146: fatal("input_service_request: no authctxt");
147:
1.1 markus 148: if (strcmp(service, "ssh-userauth") == 0) {
1.18 markus 149: if (!authctxt->success) {
1.1 markus 150: accept = 1;
151: /* now we can handle user-auth requests */
152: dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &input_userauth_request);
153: }
154: }
155: /* XXX all other service requests are denied */
156:
157: if (accept) {
158: packet_start(SSH2_MSG_SERVICE_ACCEPT);
159: packet_put_cstring(service);
160: packet_send();
161: packet_write_wait();
162: } else {
163: debug("bad service request %s", service);
164: packet_disconnect("bad service request %s", service);
165: }
166: xfree(service);
167: }
168:
169: void
1.15 markus 170: input_userauth_request(int type, int plen, void *ctxt)
1.1 markus 171: {
1.18 markus 172: Authctxt *authctxt = ctxt;
173: Authmethod *m = NULL;
1.28 markus 174: char *user, *service, *method, *style = NULL;
1.1 markus 175: int authenticated = 0;
176:
1.18 markus 177: if (authctxt == NULL)
178: fatal("input_userauth_request: no authctxt");
1.1 markus 179:
1.18 markus 180: user = packet_get_string(NULL);
181: service = packet_get_string(NULL);
182: method = packet_get_string(NULL);
1.1 markus 183: debug("userauth-request for user %s service %s method %s", user, service, method);
1.24 markus 184: debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
1.1 markus 185:
1.28 markus 186: if ((style = strchr(user, ':')) != NULL)
187: *style++ = 0;
188:
1.24 markus 189: if (authctxt->attempt++ == 0) {
1.18 markus 190: /* setup auth context */
191: struct passwd *pw = NULL;
192: setproctitle("%s", user);
193: pw = getpwnam(user);
194: if (pw && allowed_user(pw) && strcmp(service, "ssh-connection")==0) {
195: authctxt->pw = pwcopy(pw);
196: authctxt->valid = 1;
197: debug2("input_userauth_request: setting up authctxt for %s", user);
198: } else {
199: log("input_userauth_request: illegal user %s", user);
200: }
201: authctxt->user = xstrdup(user);
202: authctxt->service = xstrdup(service);
1.28 markus 203: authctxt->style = style ? xstrdup(style) : NULL; /* currently unused */
1.18 markus 204: } else if (authctxt->valid) {
205: if (strcmp(user, authctxt->user) != 0 ||
206: strcmp(service, authctxt->service) != 0) {
207: log("input_userauth_request: missmatch: (%s,%s)!=(%s,%s)",
208: user, service, authctxt->user, authctxt->service);
209: authctxt->valid = 0;
1.1 markus 210: }
211: }
1.28 markus 212: /* reset state */
213: dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, &protocol_error);
214: authctxt->postponed = 0;
1.18 markus 215:
1.28 markus 216: /* try to authenticate user */
1.18 markus 217: m = authmethod_lookup(method);
218: if (m != NULL) {
219: debug2("input_userauth_request: try method %s", method);
220: authenticated = m->userauth(authctxt);
221: }
1.28 markus 222: if (!authctxt->valid && authenticated)
223: fatal("INTERNAL ERROR: authenticated invalid user %s",
224: authctxt->user);
1.18 markus 225:
226: /* Special handling for root */
1.28 markus 227: if (authenticated && authctxt->pw->pw_uid == 0 && !auth_root_allowed())
1.3 markus 228: authenticated = 0;
229:
1.18 markus 230: /* Log before sending the reply */
1.28 markus 231: auth_log(authctxt, authenticated, method, " ssh2");
232:
233: if (!authctxt->postponed)
234: userauth_reply(authctxt, authenticated);
1.18 markus 235:
236: xfree(service);
237: xfree(user);
238: xfree(method);
239: }
240:
1.25 markus 241: void
242: userauth_banner(void)
243: {
244: struct stat st;
245: char *banner = NULL;
246: off_t len, n;
247: int fd;
248:
249: if (options.banner == NULL || (datafellows & SSH_BUG_BANNER))
250: return;
251: if ((fd = open(options.banner, O_RDONLY)) < 0) {
252: error("userauth_banner: open %s failed: %s",
253: options.banner, strerror(errno));
254: return;
255: }
256: if (fstat(fd, &st) < 0)
257: goto done;
258: len = st.st_size;
259: banner = xmalloc(len + 1);
260: if ((n = read(fd, banner, len)) < 0)
261: goto done;
262: banner[n] = '\0';
263: packet_start(SSH2_MSG_USERAUTH_BANNER);
264: packet_put_cstring(banner);
265: packet_put_cstring(""); /* language, unused */
266: packet_send();
267: debug("userauth_banner: sent");
268: done:
269: if (banner)
270: xfree(banner);
271: close(fd);
272: return;
273: }
1.18 markus 274:
275: void
276: userauth_reply(Authctxt *authctxt, int authenticated)
277: {
1.24 markus 278: char *methods;
1.28 markus 279:
1.3 markus 280: /* XXX todo: check if multiple auth methods are needed */
1.28 markus 281: if (authenticated) {
1.1 markus 282: /* turn off userauth */
283: dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &protocol_error);
284: packet_start(SSH2_MSG_USERAUTH_SUCCESS);
285: packet_send();
286: packet_write_wait();
287: /* now we can break out */
1.18 markus 288: authctxt->success = 1;
1.28 markus 289: } else {
290: if (authctxt->failures++ > AUTH_FAIL_MAX)
291: packet_disconnect(AUTH_FAIL_MSG, authctxt->user);
1.24 markus 292: methods = authmethods_get();
1.1 markus 293: packet_start(SSH2_MSG_USERAUTH_FAILURE);
1.18 markus 294: packet_put_cstring(methods);
295: packet_put_char(0); /* XXX partial success, unused */
1.1 markus 296: packet_send();
297: packet_write_wait();
1.18 markus 298: xfree(methods);
1.1 markus 299: }
300: }
301:
302: int
1.18 markus 303: userauth_none(Authctxt *authctxt)
1.1 markus 304: {
1.18 markus 305: /* disable method "none", only allowed one time */
306: Authmethod *m = authmethod_lookup("none");
307: if (m != NULL)
308: m->enabled = NULL;
1.1 markus 309: packet_done();
1.25 markus 310: userauth_banner();
1.18 markus 311: return authctxt->valid ? auth_password(authctxt->pw, "") : 0;
1.1 markus 312: }
1.18 markus 313:
1.1 markus 314: int
1.18 markus 315: userauth_passwd(Authctxt *authctxt)
1.1 markus 316: {
317: char *password;
318: int authenticated = 0;
319: int change;
1.23 markus 320: u_int len;
1.1 markus 321: change = packet_get_char();
322: if (change)
323: log("password change not supported");
324: password = packet_get_string(&len);
325: packet_done();
1.18 markus 326: if (authctxt->valid &&
327: auth_password(authctxt->pw, password) == 1)
1.1 markus 328: authenticated = 1;
329: memset(password, 0, len);
330: xfree(password);
331: return authenticated;
332: }
1.18 markus 333:
334: int
335: userauth_kbdint(Authctxt *authctxt)
336: {
337: int authenticated = 0;
338: char *lang = NULL;
339: char *devs = NULL;
340:
341: lang = packet_get_string(NULL);
342: devs = packet_get_string(NULL);
343: packet_done();
344:
345: debug("keyboard-interactive language %s devs %s", lang, devs);
1.28 markus 346:
347: authenticated = auth2_challenge(authctxt, devs);
348:
1.18 markus 349: xfree(lang);
350: xfree(devs);
351: return authenticated;
352: }
353:
1.1 markus 354: int
1.18 markus 355: userauth_pubkey(Authctxt *authctxt)
1.1 markus 356: {
357: Buffer b;
358: Key *key;
359: char *pkalg, *pkblob, *sig;
1.23 markus 360: u_int alen, blen, slen;
1.21 markus 361: int have_sig, pktype;
1.1 markus 362: int authenticated = 0;
363:
1.18 markus 364: if (!authctxt->valid) {
365: debug2("userauth_pubkey: disabled because of invalid user");
1.8 markus 366: return 0;
367: }
1.1 markus 368: have_sig = packet_get_char();
1.22 markus 369: if (datafellows & SSH_BUG_PKAUTH) {
370: debug2("userauth_pubkey: SSH_BUG_PKAUTH");
371: /* no explicit pkalg given */
372: pkblob = packet_get_string(&blen);
373: buffer_init(&b);
374: buffer_append(&b, pkblob, blen);
375: /* so we have to extract the pkalg from the pkblob */
376: pkalg = buffer_get_string(&b, &alen);
377: buffer_free(&b);
378: } else {
379: pkalg = packet_get_string(&alen);
380: pkblob = packet_get_string(&blen);
381: }
1.21 markus 382: pktype = key_type_from_name(pkalg);
383: if (pktype == KEY_UNSPEC) {
1.22 markus 384: /* this is perfectly legal */
385: log("userauth_pubkey: unsupported public key algorithm: %s", pkalg);
1.1 markus 386: xfree(pkalg);
1.22 markus 387: xfree(pkblob);
1.1 markus 388: return 0;
389: }
1.21 markus 390: key = key_from_blob(pkblob, blen);
1.2 markus 391: if (key != NULL) {
392: if (have_sig) {
393: sig = packet_get_string(&slen);
394: packet_done();
395: buffer_init(&b);
1.20 markus 396: if (datafellows & SSH_OLD_SESSIONID) {
397: buffer_append(&b, session_id2, session_id2_len);
398: } else {
1.11 markus 399: buffer_put_string(&b, session_id2, session_id2_len);
400: }
1.9 markus 401: /* reconstruct packet */
1.2 markus 402: buffer_put_char(&b, SSH2_MSG_USERAUTH_REQUEST);
1.18 markus 403: buffer_put_cstring(&b, authctxt->user);
1.9 markus 404: buffer_put_cstring(&b,
1.22 markus 405: datafellows & SSH_BUG_PKSERVICE ?
1.9 markus 406: "ssh-userauth" :
1.18 markus 407: authctxt->service);
1.22 markus 408: if (datafellows & SSH_BUG_PKAUTH) {
409: buffer_put_char(&b, have_sig);
410: } else {
411: buffer_put_cstring(&b, "publickey");
412: buffer_put_char(&b, have_sig);
413: buffer_put_cstring(&b, key_ssh_name(key));
414: }
1.9 markus 415: buffer_put_string(&b, pkblob, blen);
1.21 markus 416: #ifdef DEBUG_PK
1.2 markus 417: buffer_dump(&b);
1.1 markus 418: #endif
1.2 markus 419: /* test for correct signature */
1.21 markus 420: if (user_key_allowed(authctxt->pw, key) &&
421: key_verify(key, sig, slen, buffer_ptr(&b), buffer_len(&b)) == 1)
1.2 markus 422: authenticated = 1;
423: buffer_clear(&b);
424: xfree(sig);
425: } else {
1.18 markus 426: debug("test whether pkalg/pkblob are acceptable");
1.2 markus 427: packet_done();
1.18 markus 428:
1.2 markus 429: /* XXX fake reply and always send PK_OK ? */
1.6 markus 430: /*
431: * XXX this allows testing whether a user is allowed
432: * to login: if you happen to have a valid pubkey this
433: * message is sent. the message is NEVER sent at all
434: * if a user is not allowed to login. is this an
435: * issue? -markus
436: */
1.21 markus 437: if (user_key_allowed(authctxt->pw, key)) {
1.2 markus 438: packet_start(SSH2_MSG_USERAUTH_PK_OK);
439: packet_put_string(pkalg, alen);
440: packet_put_string(pkblob, blen);
441: packet_send();
442: packet_write_wait();
443: authenticated = -1;
444: }
1.1 markus 445: }
1.17 markus 446: if (authenticated != 1)
447: auth_clear_options();
1.2 markus 448: key_free(key);
1.1 markus 449: }
1.21 markus 450: debug2("userauth_pubkey: authenticated %d pkalg %s", authenticated, pkalg);
1.1 markus 451: xfree(pkalg);
452: xfree(pkblob);
453: return authenticated;
454: }
455:
1.18 markus 456: /* get current user */
1.1 markus 457:
458: struct passwd*
459: auth_get_user(void)
460: {
1.18 markus 461: return (x_authctxt != NULL && x_authctxt->valid) ? x_authctxt->pw : NULL;
1.1 markus 462: }
463:
1.18 markus 464: #define DELIM ","
465:
466: char *
467: authmethods_get(void)
1.1 markus 468: {
1.18 markus 469: Authmethod *method = NULL;
1.23 markus 470: u_int size = 0;
1.18 markus 471: char *list;
1.1 markus 472:
1.18 markus 473: for (method = authmethods; method->name != NULL; method++) {
474: if (strcmp(method->name, "none") == 0)
475: continue;
476: if (method->enabled != NULL && *(method->enabled) != 0) {
477: if (size != 0)
478: size += strlen(DELIM);
479: size += strlen(method->name);
1.1 markus 480: }
1.18 markus 481: }
482: size++; /* trailing '\0' */
483: list = xmalloc(size);
484: list[0] = '\0';
485:
486: for (method = authmethods; method->name != NULL; method++) {
487: if (strcmp(method->name, "none") == 0)
488: continue;
489: if (method->enabled != NULL && *(method->enabled) != 0) {
490: if (list[0] != '\0')
491: strlcat(list, DELIM, size);
492: strlcat(list, method->name, size);
1.1 markus 493: }
494: }
1.18 markus 495: return list;
496: }
497:
498: Authmethod *
499: authmethod_lookup(const char *name)
500: {
501: Authmethod *method = NULL;
502: if (name != NULL)
503: for (method = authmethods; method->name != NULL; method++)
504: if (method->enabled != NULL &&
505: *(method->enabled) != 0 &&
506: strcmp(name, method->name) == 0)
507: return method;
508: debug2("Unrecognized authentication method name: %s", name ? name : "NULL");
509: return NULL;
1.1 markus 510: }
511:
512: /* return 1 if user allows given key */
513: int
1.21 markus 514: user_key_allowed(struct passwd *pw, Key *key)
1.1 markus 515: {
1.31 markus 516: char line[8192], file[MAXPATHLEN];
1.1 markus 517: int found_key = 0;
518: FILE *f;
1.23 markus 519: u_long linenum = 0;
1.1 markus 520: struct stat st;
521: Key *found;
522:
1.18 markus 523: if (pw == NULL)
524: return 0;
525:
1.1 markus 526: /* Temporarily use the user's uid. */
527: temporarily_use_uid(pw->pw_uid);
528:
529: /* The authorized keys. */
530: snprintf(file, sizeof file, "%.500s/%.100s", pw->pw_dir,
1.29 markus 531: _PATH_SSH_USER_PERMITTED_KEYS2);
1.1 markus 532:
533: /* Fail quietly if file does not exist */
534: if (stat(file, &st) < 0) {
535: /* Restore the privileged uid. */
536: restore_uid();
537: return 0;
538: }
539: /* Open the file containing the authorized keys. */
540: f = fopen(file, "r");
541: if (!f) {
542: /* Restore the privileged uid. */
543: restore_uid();
544: return 0;
545: }
546: if (options.strict_modes) {
547: int fail = 0;
548: char buf[1024];
549: /* Check open file in order to avoid open/stat races */
550: if (fstat(fileno(f), &st) < 0 ||
551: (st.st_uid != 0 && st.st_uid != pw->pw_uid) ||
552: (st.st_mode & 022) != 0) {
1.16 markus 553: snprintf(buf, sizeof buf,
554: "%s authentication refused for %.100s: "
555: "bad ownership or modes for '%s'.",
556: key_type(key), pw->pw_name, file);
1.1 markus 557: fail = 1;
558: } else {
1.29 markus 559: /* Check path to _PATH_SSH_USER_PERMITTED_KEYS */
1.1 markus 560: int i;
561: static const char *check[] = {
1.29 markus 562: "", _PATH_SSH_USER_DIR, NULL
1.1 markus 563: };
564: for (i = 0; check[i]; i++) {
565: snprintf(line, sizeof line, "%.500s/%.100s",
566: pw->pw_dir, check[i]);
567: if (stat(line, &st) < 0 ||
568: (st.st_uid != 0 && st.st_uid != pw->pw_uid) ||
569: (st.st_mode & 022) != 0) {
570: snprintf(buf, sizeof buf,
1.16 markus 571: "%s authentication refused for %.100s: "
1.1 markus 572: "bad ownership or modes for '%s'.",
1.16 markus 573: key_type(key), pw->pw_name, line);
1.1 markus 574: fail = 1;
575: break;
576: }
577: }
578: }
579: if (fail) {
580: fclose(f);
1.12 todd 581: log("%s",buf);
1.1 markus 582: restore_uid();
583: return 0;
584: }
585: }
586: found_key = 0;
1.16 markus 587: found = key_new(key->type);
1.1 markus 588:
589: while (fgets(line, sizeof(line), f)) {
1.10 markus 590: char *cp, *options = NULL;
1.1 markus 591: linenum++;
592: /* Skip leading whitespace, empty and comment lines. */
593: for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
594: ;
595: if (!*cp || *cp == '\n' || *cp == '#')
596: continue;
1.10 markus 597:
1.21 markus 598: if (key_read(found, &cp) == -1) {
1.10 markus 599: /* no key? check if there are options for this key */
600: int quoted = 0;
1.21 markus 601: debug2("user_key_allowed: check options: '%s'", cp);
1.10 markus 602: options = cp;
603: for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
604: if (*cp == '\\' && cp[1] == '"')
605: cp++; /* Skip both */
606: else if (*cp == '"')
607: quoted = !quoted;
608: }
609: /* Skip remaining whitespace. */
610: for (; *cp == ' ' || *cp == '\t'; cp++)
611: ;
1.21 markus 612: if (key_read(found, &cp) == -1) {
613: debug2("user_key_allowed: advance: '%s'", cp);
1.10 markus 614: /* still no key? advance to next line*/
615: continue;
616: }
617: }
618: if (key_equal(found, key) &&
1.30 markus 619: auth_parse_options(pw, options, file, linenum) == 1) {
1.1 markus 620: found_key = 1;
621: debug("matching key found: file %s, line %ld",
622: file, linenum);
623: break;
624: }
625: }
626: restore_uid();
627: fclose(f);
628: key_free(found);
629: return found_key;
630: }