Annotation of src/usr.bin/ssh/monitor_wrap.c, Revision 1.64
1.64 ! djm 1: /* $OpenBSD: monitor_wrap.c,v 1.63 2008/07/10 18:08:11 markus Exp $ */
1.1 provos 2: /*
3: * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4: * Copyright 2002 Markus Friedl <markus@openbsd.org>
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26: */
27:
1.46 stevesk 28: #include <sys/types.h>
1.51 dtucker 29: #include <sys/uio.h>
1.61 djm 30: #include <sys/queue.h>
1.46 stevesk 31:
1.1 provos 32: #include <openssl/bn.h>
33: #include <openssl/dh.h>
1.64 ! djm 34: #include <openssl/evp.h>
1.46 stevesk 35:
1.47 stevesk 36: #include <errno.h>
1.46 stevesk 37: #include <pwd.h>
1.50 deraadt 38: #include <signal.h>
1.49 stevesk 39: #include <stdio.h>
1.48 stevesk 40: #include <string.h>
1.51 dtucker 41: #include <unistd.h>
1.1 provos 42:
1.50 deraadt 43: #include "xmalloc.h"
1.1 provos 44: #include "ssh.h"
45: #include "dh.h"
1.50 deraadt 46: #include "buffer.h"
47: #include "key.h"
48: #include "cipher.h"
1.1 provos 49: #include "kex.h"
1.50 deraadt 50: #include "hostfile.h"
1.1 provos 51: #include "auth.h"
1.22 markus 52: #include "auth-options.h"
1.1 provos 53: #include "packet.h"
54: #include "mac.h"
55: #include "log.h"
1.54 miod 56: #include <zlib.h>
1.1 provos 57: #include "monitor.h"
1.50 deraadt 58: #ifdef GSSAPI
59: #include "ssh-gss.h"
60: #endif
1.1 provos 61: #include "monitor_wrap.h"
62: #include "atomicio.h"
63: #include "monitor_fdpass.h"
1.45 djm 64: #include "misc.h"
1.64 ! djm 65: #include "jpake.h"
1.1 provos 66:
67: #include "channels.h"
68: #include "session.h"
1.55 dtucker 69: #include "servconf.h"
1.29 markus 70:
1.1 provos 71: /* Imports */
72: extern int compat20;
73: extern Newkeys *newkeys[];
74: extern z_stream incoming_stream;
75: extern z_stream outgoing_stream;
1.7 mouring 76: extern struct monitor *pmonitor;
1.1 provos 77: extern Buffer input, output;
1.39 dtucker 78: extern Buffer loginmsg;
1.55 dtucker 79: extern ServerOptions options;
1.1 provos 80:
1.32 markus 81: int
82: mm_is_monitor(void)
83: {
84: /*
85: * m_pid is only set in the privileged part, and
86: * points to the unprivileged child.
87: */
1.34 markus 88: return (pmonitor && pmonitor->m_pid > 0);
1.32 markus 89: }
90:
1.1 provos 91: void
1.36 avsm 92: mm_request_send(int sock, enum monitor_reqtype type, Buffer *m)
1.1 provos 93: {
1.13 deraadt 94: u_int mlen = buffer_len(m);
1.1 provos 95: u_char buf[5];
96:
1.8 markus 97: debug3("%s entering: type %d", __func__, type);
1.1 provos 98:
1.45 djm 99: put_u32(buf, mlen + 1);
1.10 deraadt 100: buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */
1.36 avsm 101: if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf))
1.40 avsm 102: fatal("%s: write: %s", __func__, strerror(errno));
1.36 avsm 103: if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen)
1.40 avsm 104: fatal("%s: write: %s", __func__, strerror(errno));
1.1 provos 105: }
106:
107: void
1.36 avsm 108: mm_request_receive(int sock, Buffer *m)
1.1 provos 109: {
110: u_char buf[4];
1.13 deraadt 111: u_int msg_len;
1.1 provos 112:
1.8 markus 113: debug3("%s entering", __func__);
1.1 provos 114:
1.40 avsm 115: if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) {
116: if (errno == EPIPE)
1.32 markus 117: cleanup_exit(255);
1.40 avsm 118: fatal("%s: read: %s", __func__, strerror(errno));
1.1 provos 119: }
1.45 djm 120: msg_len = get_u32(buf);
1.1 provos 121: if (msg_len > 256 * 1024)
1.8 markus 122: fatal("%s: read: bad msg_len %d", __func__, msg_len);
1.1 provos 123: buffer_clear(m);
124: buffer_append_space(m, msg_len);
1.40 avsm 125: if (atomicio(read, sock, buffer_ptr(m), msg_len) != msg_len)
126: fatal("%s: read: %s", __func__, strerror(errno));
1.1 provos 127: }
128:
129: void
1.36 avsm 130: mm_request_receive_expect(int sock, enum monitor_reqtype type, Buffer *m)
1.1 provos 131: {
132: u_char rtype;
133:
1.8 markus 134: debug3("%s entering: type %d", __func__, type);
1.1 provos 135:
1.36 avsm 136: mm_request_receive(sock, m);
1.1 provos 137: rtype = buffer_get_char(m);
138: if (rtype != type)
1.8 markus 139: fatal("%s: read: rtype %d != type %d", __func__,
1.1 provos 140: rtype, type);
141: }
142:
143: DH *
144: mm_choose_dh(int min, int nbits, int max)
145: {
146: BIGNUM *p, *g;
147: int success = 0;
148: Buffer m;
149:
150: buffer_init(&m);
151: buffer_put_int(&m, min);
152: buffer_put_int(&m, nbits);
153: buffer_put_int(&m, max);
154:
1.7 mouring 155: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_MODULI, &m);
1.1 provos 156:
1.8 markus 157: debug3("%s: waiting for MONITOR_ANS_MODULI", __func__);
1.7 mouring 158: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_MODULI, &m);
1.1 provos 159:
160: success = buffer_get_char(&m);
161: if (success == 0)
1.8 markus 162: fatal("%s: MONITOR_ANS_MODULI failed", __func__);
1.1 provos 163:
164: if ((p = BN_new()) == NULL)
1.8 markus 165: fatal("%s: BN_new failed", __func__);
1.3 markus 166: if ((g = BN_new()) == NULL)
1.8 markus 167: fatal("%s: BN_new failed", __func__);
1.1 provos 168: buffer_get_bignum2(&m, p);
169: buffer_get_bignum2(&m, g);
170:
1.8 markus 171: debug3("%s: remaining %d", __func__, buffer_len(&m));
1.1 provos 172: buffer_free(&m);
173:
174: return (dh_new_group(g, p));
175: }
176:
177: int
178: mm_key_sign(Key *key, u_char **sigp, u_int *lenp, u_char *data, u_int datalen)
179: {
1.7 mouring 180: Kex *kex = *pmonitor->m_pkex;
1.1 provos 181: Buffer m;
182:
1.8 markus 183: debug3("%s entering", __func__);
1.1 provos 184:
185: buffer_init(&m);
186: buffer_put_int(&m, kex->host_key_index(key));
187: buffer_put_string(&m, data, datalen);
188:
1.7 mouring 189: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SIGN, &m);
1.1 provos 190:
1.8 markus 191: debug3("%s: waiting for MONITOR_ANS_SIGN", __func__);
1.7 mouring 192: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SIGN, &m);
1.1 provos 193: *sigp = buffer_get_string(&m, lenp);
194: buffer_free(&m);
195:
196: return (0);
197: }
198:
199: struct passwd *
1.37 dtucker 200: mm_getpwnamallow(const char *username)
1.1 provos 201: {
202: Buffer m;
203: struct passwd *pw;
1.55 dtucker 204: u_int len;
205: ServerOptions *newopts;
1.1 provos 206:
1.8 markus 207: debug3("%s entering", __func__);
1.1 provos 208:
209: buffer_init(&m);
1.37 dtucker 210: buffer_put_cstring(&m, username);
1.1 provos 211:
1.7 mouring 212: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PWNAM, &m);
1.1 provos 213:
1.8 markus 214: debug3("%s: waiting for MONITOR_ANS_PWNAM", __func__);
1.7 mouring 215: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PWNAM, &m);
1.1 provos 216:
217: if (buffer_get_char(&m) == 0) {
1.60 dtucker 218: pw = NULL;
219: goto out;
1.1 provos 220: }
1.55 dtucker 221: pw = buffer_get_string(&m, &len);
222: if (len != sizeof(struct passwd))
1.8 markus 223: fatal("%s: struct passwd size mismatch", __func__);
1.1 provos 224: pw->pw_name = buffer_get_string(&m, NULL);
225: pw->pw_passwd = buffer_get_string(&m, NULL);
226: pw->pw_gecos = buffer_get_string(&m, NULL);
227: pw->pw_class = buffer_get_string(&m, NULL);
228: pw->pw_dir = buffer_get_string(&m, NULL);
229: pw->pw_shell = buffer_get_string(&m, NULL);
1.55 dtucker 230:
1.60 dtucker 231: out:
1.55 dtucker 232: /* copy options block as a Match directive may have changed some */
233: newopts = buffer_get_string(&m, &len);
234: if (len != sizeof(*newopts))
235: fatal("%s: option block size mismatch", __func__);
236: if (newopts->banner != NULL)
237: newopts->banner = buffer_get_string(&m, NULL);
238: copy_set_server_options(&options, newopts, 1);
239: xfree(newopts);
240:
1.1 provos 241: buffer_free(&m);
242:
243: return (pw);
1.6 djm 244: }
245:
1.33 markus 246: char *
247: mm_auth2_read_banner(void)
1.6 djm 248: {
249: Buffer m;
250: char *banner;
251:
1.8 markus 252: debug3("%s entering", __func__);
1.6 djm 253:
254: buffer_init(&m);
1.7 mouring 255: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTH2_READ_BANNER, &m);
1.6 djm 256: buffer_clear(&m);
257:
1.33 markus 258: mm_request_receive_expect(pmonitor->m_recvfd,
259: MONITOR_ANS_AUTH2_READ_BANNER, &m);
1.6 djm 260: banner = buffer_get_string(&m, NULL);
261: buffer_free(&m);
1.10 deraadt 262:
1.33 markus 263: /* treat empty banner as missing banner */
264: if (strlen(banner) == 0) {
265: xfree(banner);
266: banner = NULL;
267: }
1.6 djm 268: return (banner);
1.1 provos 269: }
270:
271: /* Inform the privileged process about service and style */
272:
273: void
274: mm_inform_authserv(char *service, char *style)
275: {
276: Buffer m;
277:
1.8 markus 278: debug3("%s entering", __func__);
1.1 provos 279:
280: buffer_init(&m);
281: buffer_put_cstring(&m, service);
282: buffer_put_cstring(&m, style ? style : "");
283:
1.7 mouring 284: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHSERV, &m);
1.1 provos 285:
286: buffer_free(&m);
287: }
288:
289: /* Do the password authentication */
290: int
291: mm_auth_password(Authctxt *authctxt, char *password)
292: {
293: Buffer m;
294: int authenticated = 0;
295:
1.8 markus 296: debug3("%s entering", __func__);
1.1 provos 297:
298: buffer_init(&m);
299: buffer_put_cstring(&m, password);
1.7 mouring 300: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHPASSWORD, &m);
1.1 provos 301:
1.8 markus 302: debug3("%s: waiting for MONITOR_ANS_AUTHPASSWORD", __func__);
1.7 mouring 303: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUTHPASSWORD, &m);
1.1 provos 304:
305: authenticated = buffer_get_int(&m);
306:
307: buffer_free(&m);
308:
1.3 markus 309: debug3("%s: user %sauthenticated",
1.8 markus 310: __func__, authenticated ? "" : "not ");
1.1 provos 311: return (authenticated);
312: }
313:
314: int
315: mm_user_key_allowed(struct passwd *pw, Key *key)
316: {
317: return (mm_key_allowed(MM_USERKEY, NULL, NULL, key));
318: }
319:
320: int
321: mm_hostbased_key_allowed(struct passwd *pw, char *user, char *host,
322: Key *key)
323: {
324: return (mm_key_allowed(MM_HOSTKEY, user, host, key));
325: }
326:
327: int
328: mm_auth_rhosts_rsa_key_allowed(struct passwd *pw, char *user,
329: char *host, Key *key)
330: {
331: int ret;
332:
333: key->type = KEY_RSA; /* XXX hack for key_to_blob */
334: ret = mm_key_allowed(MM_RSAHOSTKEY, user, host, key);
335: key->type = KEY_RSA1;
336: return (ret);
337: }
338:
1.2 markus 339: static void
1.1 provos 340: mm_send_debug(Buffer *m)
341: {
342: char *msg;
343:
344: while (buffer_len(m)) {
345: msg = buffer_get_string(m, NULL);
1.8 markus 346: debug3("%s: Sending debug: %s", __func__, msg);
1.1 provos 347: packet_send_debug("%s", msg);
348: xfree(msg);
349: }
350: }
351:
352: int
353: mm_key_allowed(enum mm_keytype type, char *user, char *host, Key *key)
354: {
355: Buffer m;
356: u_char *blob;
357: u_int len;
1.22 markus 358: int allowed = 0, have_forced = 0;
1.1 provos 359:
1.8 markus 360: debug3("%s entering", __func__);
1.1 provos 361:
362: /* Convert the key to a blob and the pass it over */
363: if (!key_to_blob(key, &blob, &len))
364: return (0);
365:
366: buffer_init(&m);
367: buffer_put_int(&m, type);
368: buffer_put_cstring(&m, user ? user : "");
369: buffer_put_cstring(&m, host ? host : "");
370: buffer_put_string(&m, blob, len);
371: xfree(blob);
372:
1.7 mouring 373: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYALLOWED, &m);
1.1 provos 374:
1.8 markus 375: debug3("%s: waiting for MONITOR_ANS_KEYALLOWED", __func__);
1.7 mouring 376: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KEYALLOWED, &m);
1.1 provos 377:
378: allowed = buffer_get_int(&m);
379:
1.22 markus 380: /* fake forced command */
381: auth_clear_options();
382: have_forced = buffer_get_int(&m);
383: forced_command = have_forced ? xstrdup("true") : NULL;
384:
1.1 provos 385: /* Send potential debug messages */
386: mm_send_debug(&m);
387:
388: buffer_free(&m);
389:
390: return (allowed);
391: }
392:
1.3 markus 393: /*
1.1 provos 394: * This key verify needs to send the key type along, because the
395: * privileged parent makes the decision if the key is allowed
396: * for authentication.
397: */
398:
399: int
400: mm_key_verify(Key *key, u_char *sig, u_int siglen, u_char *data, u_int datalen)
401: {
402: Buffer m;
403: u_char *blob;
404: u_int len;
405: int verified = 0;
406:
1.8 markus 407: debug3("%s entering", __func__);
1.1 provos 408:
409: /* Convert the key to a blob and the pass it over */
410: if (!key_to_blob(key, &blob, &len))
411: return (0);
412:
413: buffer_init(&m);
414: buffer_put_string(&m, blob, len);
415: buffer_put_string(&m, sig, siglen);
416: buffer_put_string(&m, data, datalen);
417: xfree(blob);
418:
1.7 mouring 419: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_KEYVERIFY, &m);
1.1 provos 420:
1.8 markus 421: debug3("%s: waiting for MONITOR_ANS_KEYVERIFY", __func__);
1.7 mouring 422: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_KEYVERIFY, &m);
1.1 provos 423:
424: verified = buffer_get_int(&m);
425:
426: buffer_free(&m);
427:
428: return (verified);
429: }
430:
431: /* Export key state after authentication */
432: Newkeys *
433: mm_newkeys_from_blob(u_char *blob, int blen)
434: {
435: Buffer b;
436: u_int len;
437: Newkeys *newkey = NULL;
438: Enc *enc;
439: Mac *mac;
440: Comp *comp;
441:
1.8 markus 442: debug3("%s: %p(%d)", __func__, blob, blen);
1.1 provos 443: #ifdef DEBUG_PK
444: dump_base64(stderr, blob, blen);
445: #endif
446: buffer_init(&b);
447: buffer_append(&b, blob, blen);
448:
449: newkey = xmalloc(sizeof(*newkey));
450: enc = &newkey->enc;
451: mac = &newkey->mac;
452: comp = &newkey->comp;
453:
454: /* Enc structure */
455: enc->name = buffer_get_string(&b, NULL);
456: buffer_get(&b, &enc->cipher, sizeof(enc->cipher));
457: enc->enabled = buffer_get_int(&b);
458: enc->block_size = buffer_get_int(&b);
459: enc->key = buffer_get_string(&b, &enc->key_len);
460: enc->iv = buffer_get_string(&b, &len);
461: if (len != enc->block_size)
1.12 deraadt 462: fatal("%s: bad ivlen: expected %u != %u", __func__,
1.1 provos 463: enc->block_size, len);
464:
465: if (enc->name == NULL || cipher_by_name(enc->name) != enc->cipher)
1.8 markus 466: fatal("%s: bad cipher name %s or pointer %p", __func__,
1.1 provos 467: enc->name, enc->cipher);
468:
469: /* Mac structure */
470: mac->name = buffer_get_string(&b, NULL);
1.56 djm 471: if (mac->name == NULL || mac_setup(mac, mac->name) == -1)
1.57 pvalchev 472: fatal("%s: can not setup mac %s", __func__, mac->name);
1.1 provos 473: mac->enabled = buffer_get_int(&b);
474: mac->key = buffer_get_string(&b, &len);
475: if (len > mac->key_len)
1.12 deraadt 476: fatal("%s: bad mac key length: %u > %d", __func__, len,
1.1 provos 477: mac->key_len);
478: mac->key_len = len;
479:
480: /* Comp structure */
481: comp->type = buffer_get_int(&b);
482: comp->enabled = buffer_get_int(&b);
483: comp->name = buffer_get_string(&b, NULL);
484:
485: len = buffer_len(&b);
486: if (len != 0)
1.12 deraadt 487: error("newkeys_from_blob: remaining bytes in blob %u", len);
1.1 provos 488: buffer_free(&b);
489: return (newkey);
490: }
491:
492: int
493: mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp)
494: {
495: Buffer b;
496: int len;
497: Enc *enc;
498: Mac *mac;
499: Comp *comp;
500: Newkeys *newkey = newkeys[mode];
501:
1.8 markus 502: debug3("%s: converting %p", __func__, newkey);
1.1 provos 503:
504: if (newkey == NULL) {
1.8 markus 505: error("%s: newkey == NULL", __func__);
1.1 provos 506: return 0;
507: }
508: enc = &newkey->enc;
509: mac = &newkey->mac;
510: comp = &newkey->comp;
511:
512: buffer_init(&b);
513: /* Enc structure */
514: buffer_put_cstring(&b, enc->name);
515: /* The cipher struct is constant and shared, you export pointer */
516: buffer_append(&b, &enc->cipher, sizeof(enc->cipher));
517: buffer_put_int(&b, enc->enabled);
518: buffer_put_int(&b, enc->block_size);
519: buffer_put_string(&b, enc->key, enc->key_len);
520: packet_get_keyiv(mode, enc->iv, enc->block_size);
521: buffer_put_string(&b, enc->iv, enc->block_size);
522:
523: /* Mac structure */
524: buffer_put_cstring(&b, mac->name);
525: buffer_put_int(&b, mac->enabled);
526: buffer_put_string(&b, mac->key, mac->key_len);
527:
528: /* Comp structure */
529: buffer_put_int(&b, comp->type);
530: buffer_put_int(&b, comp->enabled);
531: buffer_put_cstring(&b, comp->name);
532:
533: len = buffer_len(&b);
1.16 markus 534: if (lenp != NULL)
535: *lenp = len;
536: if (blobp != NULL) {
537: *blobp = xmalloc(len);
538: memcpy(*blobp, buffer_ptr(&b), len);
539: }
1.1 provos 540: memset(buffer_ptr(&b), 0, len);
541: buffer_free(&b);
542: return len;
543: }
544:
1.2 markus 545: static void
1.1 provos 546: mm_send_kex(Buffer *m, Kex *kex)
547: {
548: buffer_put_string(m, kex->session_id, kex->session_id_len);
549: buffer_put_int(m, kex->we_need);
550: buffer_put_int(m, kex->hostkey_type);
551: buffer_put_int(m, kex->kex_type);
552: buffer_put_string(m, buffer_ptr(&kex->my), buffer_len(&kex->my));
553: buffer_put_string(m, buffer_ptr(&kex->peer), buffer_len(&kex->peer));
554: buffer_put_int(m, kex->flags);
555: buffer_put_cstring(m, kex->client_version_string);
556: buffer_put_cstring(m, kex->server_version_string);
557: }
558:
559: void
1.36 avsm 560: mm_send_keystate(struct monitor *monitor)
1.1 provos 561: {
562: Buffer m;
563: u_char *blob, *p;
564: u_int bloblen, plen;
1.25 markus 565: u_int32_t seqnr, packets;
1.63 markus 566: u_int64_t blocks, bytes;
1.1 provos 567:
568: buffer_init(&m);
569:
570: if (!compat20) {
571: u_char iv[24];
1.11 markus 572: u_char *key;
573: u_int ivlen, keylen;
1.1 provos 574:
575: buffer_put_int(&m, packet_get_protocol_flags());
576:
577: buffer_put_int(&m, packet_get_ssh1_cipher());
578:
1.11 markus 579: debug3("%s: Sending ssh1 KEY+IV", __func__);
580: keylen = packet_get_encryption_key(NULL);
581: key = xmalloc(keylen+1); /* add 1 if keylen == 0 */
582: keylen = packet_get_encryption_key(key);
583: buffer_put_string(&m, key, keylen);
584: memset(key, 0, keylen);
585: xfree(key);
586:
1.1 provos 587: ivlen = packet_get_keyiv_len(MODE_OUT);
588: packet_get_keyiv(MODE_OUT, iv, ivlen);
589: buffer_put_string(&m, iv, ivlen);
590: ivlen = packet_get_keyiv_len(MODE_OUT);
591: packet_get_keyiv(MODE_IN, iv, ivlen);
592: buffer_put_string(&m, iv, ivlen);
593: goto skip;
594: } else {
595: /* Kex for rekeying */
1.36 avsm 596: mm_send_kex(&m, *monitor->m_pkex);
1.1 provos 597: }
598:
599: debug3("%s: Sending new keys: %p %p",
1.8 markus 600: __func__, newkeys[MODE_OUT], newkeys[MODE_IN]);
1.1 provos 601:
602: /* Keys from Kex */
603: if (!mm_newkeys_to_blob(MODE_OUT, &blob, &bloblen))
1.8 markus 604: fatal("%s: conversion of newkeys failed", __func__);
1.1 provos 605:
606: buffer_put_string(&m, blob, bloblen);
607: xfree(blob);
608:
609: if (!mm_newkeys_to_blob(MODE_IN, &blob, &bloblen))
1.8 markus 610: fatal("%s: conversion of newkeys failed", __func__);
1.1 provos 611:
612: buffer_put_string(&m, blob, bloblen);
613: xfree(blob);
614:
1.63 markus 615: packet_get_state(MODE_OUT, &seqnr, &blocks, &packets, &bytes);
1.25 markus 616: buffer_put_int(&m, seqnr);
617: buffer_put_int64(&m, blocks);
618: buffer_put_int(&m, packets);
1.63 markus 619: buffer_put_int64(&m, bytes);
620: packet_get_state(MODE_IN, &seqnr, &blocks, &packets, &bytes);
1.25 markus 621: buffer_put_int(&m, seqnr);
622: buffer_put_int64(&m, blocks);
623: buffer_put_int(&m, packets);
1.63 markus 624: buffer_put_int64(&m, bytes);
1.1 provos 625:
1.8 markus 626: debug3("%s: New keys have been sent", __func__);
1.1 provos 627: skip:
628: /* More key context */
629: plen = packet_get_keycontext(MODE_OUT, NULL);
630: p = xmalloc(plen+1);
631: packet_get_keycontext(MODE_OUT, p);
632: buffer_put_string(&m, p, plen);
633: xfree(p);
634:
635: plen = packet_get_keycontext(MODE_IN, NULL);
636: p = xmalloc(plen+1);
637: packet_get_keycontext(MODE_IN, p);
638: buffer_put_string(&m, p, plen);
639: xfree(p);
640:
641: /* Compression state */
1.8 markus 642: debug3("%s: Sending compression state", __func__);
1.1 provos 643: buffer_put_string(&m, &outgoing_stream, sizeof(outgoing_stream));
644: buffer_put_string(&m, &incoming_stream, sizeof(incoming_stream));
645:
646: /* Network I/O buffers */
647: buffer_put_string(&m, buffer_ptr(&input), buffer_len(&input));
648: buffer_put_string(&m, buffer_ptr(&output), buffer_len(&output));
649:
1.36 avsm 650: mm_request_send(monitor->m_recvfd, MONITOR_REQ_KEYEXPORT, &m);
1.8 markus 651: debug3("%s: Finished sending state", __func__);
1.1 provos 652:
653: buffer_free(&m);
654: }
655:
656: int
1.42 deraadt 657: mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
1.1 provos 658: {
659: Buffer m;
1.39 dtucker 660: char *p, *msg;
1.62 djm 661: int success = 0, tmp1 = -1, tmp2 = -1;
662:
663: /* Kludge: ensure there are fds free to receive the pty/tty */
664: if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
665: (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
666: error("%s: cannot allocate fds for pty", __func__);
667: if (tmp1 > 0)
668: close(tmp1);
669: if (tmp2 > 0)
670: close(tmp2);
671: return 0;
672: }
673: close(tmp1);
674: close(tmp2);
1.1 provos 675:
676: buffer_init(&m);
1.7 mouring 677: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTY, &m);
1.1 provos 678:
1.8 markus 679: debug3("%s: waiting for MONITOR_ANS_PTY", __func__);
1.7 mouring 680: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PTY, &m);
1.1 provos 681:
682: success = buffer_get_int(&m);
683: if (success == 0) {
1.8 markus 684: debug3("%s: pty alloc failed", __func__);
1.1 provos 685: buffer_free(&m);
686: return (0);
687: }
688: p = buffer_get_string(&m, NULL);
1.39 dtucker 689: msg = buffer_get_string(&m, NULL);
1.1 provos 690: buffer_free(&m);
691:
692: strlcpy(namebuf, p, namebuflen); /* Possible truncation */
693: xfree(p);
1.39 dtucker 694:
695: buffer_append(&loginmsg, msg, strlen(msg));
696: xfree(msg);
1.1 provos 697:
1.58 djm 698: if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 ||
699: (*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1)
700: fatal("%s: receive fds failed", __func__);
1.1 provos 701:
702: /* Success */
703: return (1);
704: }
705:
706: void
1.32 markus 707: mm_session_pty_cleanup2(Session *s)
1.1 provos 708: {
709: Buffer m;
710:
711: if (s->ttyfd == -1)
712: return;
713: buffer_init(&m);
714: buffer_put_cstring(&m, s->tty);
1.7 mouring 715: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTYCLEANUP, &m);
1.1 provos 716: buffer_free(&m);
1.3 markus 717:
1.1 provos 718: /* closed dup'ed master */
1.62 djm 719: if (s->ptymaster != -1 && close(s->ptymaster) < 0)
720: error("close(s->ptymaster/%d): %s",
721: s->ptymaster, strerror(errno));
1.1 provos 722:
723: /* unlink pty from session */
724: s->ttyfd = -1;
725: }
726:
727: /* Request process termination */
728:
729: void
730: mm_terminate(void)
731: {
732: Buffer m;
733:
734: buffer_init(&m);
1.7 mouring 735: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_TERM, &m);
1.1 provos 736: buffer_free(&m);
737: }
738:
739: int
740: mm_ssh1_session_key(BIGNUM *num)
741: {
742: int rsafail;
743: Buffer m;
744:
745: buffer_init(&m);
746: buffer_put_bignum2(&m, num);
1.7 mouring 747: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SESSKEY, &m);
1.1 provos 748:
1.7 mouring 749: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SESSKEY, &m);
1.1 provos 750:
751: rsafail = buffer_get_int(&m);
752: buffer_get_bignum2(&m, num);
753:
754: buffer_free(&m);
755:
756: return (rsafail);
757: }
758:
1.2 markus 759: static void
1.1 provos 760: mm_chall_setup(char **name, char **infotxt, u_int *numprompts,
761: char ***prompts, u_int **echo_on)
762: {
1.10 deraadt 763: *name = xstrdup("");
764: *infotxt = xstrdup("");
1.1 provos 765: *numprompts = 1;
1.43 djm 766: *prompts = xcalloc(*numprompts, sizeof(char *));
767: *echo_on = xcalloc(*numprompts, sizeof(u_int));
1.1 provos 768: (*echo_on)[0] = 0;
769: }
770:
771: int
772: mm_bsdauth_query(void *ctx, char **name, char **infotxt,
773: u_int *numprompts, char ***prompts, u_int **echo_on)
774: {
775: Buffer m;
1.21 markus 776: u_int success;
1.1 provos 777: char *challenge;
778:
1.8 markus 779: debug3("%s: entering", __func__);
1.1 provos 780:
781: buffer_init(&m);
1.7 mouring 782: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHQUERY, &m);
1.1 provos 783:
1.7 mouring 784: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_BSDAUTHQUERY,
1.1 provos 785: &m);
1.21 markus 786: success = buffer_get_int(&m);
787: if (success == 0) {
1.8 markus 788: debug3("%s: no challenge", __func__);
1.1 provos 789: buffer_free(&m);
790: return (-1);
791: }
792:
793: /* Get the challenge, and format the response */
794: challenge = buffer_get_string(&m, NULL);
795: buffer_free(&m);
796:
797: mm_chall_setup(name, infotxt, numprompts, prompts, echo_on);
798: (*prompts)[0] = challenge;
799:
1.8 markus 800: debug3("%s: received challenge: %s", __func__, challenge);
1.1 provos 801:
802: return (0);
803: }
804:
805: int
806: mm_bsdauth_respond(void *ctx, u_int numresponses, char **responses)
807: {
808: Buffer m;
809: int authok;
810:
1.8 markus 811: debug3("%s: entering", __func__);
1.1 provos 812: if (numresponses != 1)
813: return (-1);
814:
815: buffer_init(&m);
816: buffer_put_cstring(&m, responses[0]);
1.7 mouring 817: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_BSDAUTHRESPOND, &m);
1.1 provos 818:
1.7 mouring 819: mm_request_receive_expect(pmonitor->m_recvfd,
1.1 provos 820: MONITOR_ANS_BSDAUTHRESPOND, &m);
821:
822: authok = buffer_get_int(&m);
823: buffer_free(&m);
824:
825: return ((authok == 0) ? -1 : 0);
826: }
827:
828:
829: void
830: mm_ssh1_session_id(u_char session_id[16])
831: {
832: Buffer m;
833: int i;
834:
1.8 markus 835: debug3("%s entering", __func__);
1.1 provos 836:
837: buffer_init(&m);
838: for (i = 0; i < 16; i++)
839: buffer_put_char(&m, session_id[i]);
840:
1.7 mouring 841: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SESSID, &m);
1.1 provos 842: buffer_free(&m);
843: }
844:
845: int
846: mm_auth_rsa_key_allowed(struct passwd *pw, BIGNUM *client_n, Key **rkey)
847: {
848: Buffer m;
849: Key *key;
850: u_char *blob;
851: u_int blen;
1.22 markus 852: int allowed = 0, have_forced = 0;
1.1 provos 853:
1.8 markus 854: debug3("%s entering", __func__);
1.1 provos 855:
856: buffer_init(&m);
857: buffer_put_bignum2(&m, client_n);
858:
1.7 mouring 859: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSAKEYALLOWED, &m);
860: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSAKEYALLOWED, &m);
1.1 provos 861:
862: allowed = buffer_get_int(&m);
1.22 markus 863:
864: /* fake forced command */
865: auth_clear_options();
866: have_forced = buffer_get_int(&m);
867: forced_command = have_forced ? xstrdup("true") : NULL;
1.1 provos 868:
869: if (allowed && rkey != NULL) {
870: blob = buffer_get_string(&m, &blen);
871: if ((key = key_from_blob(blob, blen)) == NULL)
1.8 markus 872: fatal("%s: key_from_blob failed", __func__);
1.1 provos 873: *rkey = key;
874: xfree(blob);
875: }
876: mm_send_debug(&m);
877: buffer_free(&m);
878:
879: return (allowed);
880: }
881:
882: BIGNUM *
883: mm_auth_rsa_generate_challenge(Key *key)
884: {
885: Buffer m;
886: BIGNUM *challenge;
887: u_char *blob;
888: u_int blen;
889:
1.8 markus 890: debug3("%s entering", __func__);
1.1 provos 891:
892: if ((challenge = BN_new()) == NULL)
1.8 markus 893: fatal("%s: BN_new failed", __func__);
1.1 provos 894:
895: key->type = KEY_RSA; /* XXX cheat for key_to_blob */
896: if (key_to_blob(key, &blob, &blen) == 0)
1.8 markus 897: fatal("%s: key_to_blob failed", __func__);
1.1 provos 898: key->type = KEY_RSA1;
899:
900: buffer_init(&m);
901: buffer_put_string(&m, blob, blen);
902: xfree(blob);
903:
1.7 mouring 904: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSACHALLENGE, &m);
905: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSACHALLENGE, &m);
1.1 provos 906:
907: buffer_get_bignum2(&m, challenge);
908: buffer_free(&m);
909:
910: return (challenge);
911: }
912:
913: int
914: mm_auth_rsa_verify_response(Key *key, BIGNUM *p, u_char response[16])
915: {
916: Buffer m;
917: u_char *blob;
918: u_int blen;
919: int success = 0;
920:
1.8 markus 921: debug3("%s entering", __func__);
1.1 provos 922:
923: key->type = KEY_RSA; /* XXX cheat for key_to_blob */
924: if (key_to_blob(key, &blob, &blen) == 0)
1.8 markus 925: fatal("%s: key_to_blob failed", __func__);
1.1 provos 926: key->type = KEY_RSA1;
927:
928: buffer_init(&m);
929: buffer_put_string(&m, blob, blen);
930: buffer_put_string(&m, response, 16);
931: xfree(blob);
932:
1.7 mouring 933: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_RSARESPONSE, &m);
934: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_RSARESPONSE, &m);
1.1 provos 935:
936: success = buffer_get_int(&m);
937: buffer_free(&m);
938:
939: return (success);
940: }
1.29 markus 941:
942: #ifdef GSSAPI
943: OM_uint32
1.36 avsm 944: mm_ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID goid)
1.29 markus 945: {
946: Buffer m;
947: OM_uint32 major;
948:
949: /* Client doesn't get to see the context */
950: *ctx = NULL;
951:
952: buffer_init(&m);
1.36 avsm 953: buffer_put_string(&m, goid->elements, goid->length);
1.29 markus 954:
955: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSETUP, &m);
956: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSETUP, &m);
957:
958: major = buffer_get_int(&m);
959:
960: buffer_free(&m);
961: return (major);
962: }
963:
964: OM_uint32
965: mm_ssh_gssapi_accept_ctx(Gssctxt *ctx, gss_buffer_desc *in,
966: gss_buffer_desc *out, OM_uint32 *flags)
967: {
968: Buffer m;
969: OM_uint32 major;
1.30 deraadt 970: u_int len;
1.29 markus 971:
972: buffer_init(&m);
973: buffer_put_string(&m, in->value, in->length);
974:
975: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSTEP, &m);
976: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSTEP, &m);
977:
978: major = buffer_get_int(&m);
1.30 deraadt 979: out->value = buffer_get_string(&m, &len);
980: out->length = len;
1.29 markus 981: if (flags)
982: *flags = buffer_get_int(&m);
983:
984: buffer_free(&m);
985:
986: return (major);
1.35 markus 987: }
988:
989: OM_uint32
990: mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
991: {
992: Buffer m;
993: OM_uint32 major;
994:
995: buffer_init(&m);
996: buffer_put_string(&m, gssbuf->value, gssbuf->length);
997: buffer_put_string(&m, gssmic->value, gssmic->length);
998:
999: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSCHECKMIC, &m);
1000: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSCHECKMIC,
1001: &m);
1002:
1003: major = buffer_get_int(&m);
1004: buffer_free(&m);
1005: return(major);
1.29 markus 1006: }
1007:
1008: int
1009: mm_ssh_gssapi_userok(char *user)
1010: {
1011: Buffer m;
1012: int authenticated = 0;
1013:
1014: buffer_init(&m);
1015:
1016: mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUSEROK, &m);
1017: mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSUSEROK,
1018: &m);
1019:
1020: authenticated = buffer_get_int(&m);
1021:
1022: buffer_free(&m);
1023: debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
1024: return (authenticated);
1025: }
1026: #endif /* GSSAPI */
1.64 ! djm 1027:
! 1028: #ifdef JPAKE
! 1029: void
! 1030: mm_auth2_jpake_get_pwdata(Authctxt *authctxt, BIGNUM **s,
! 1031: char **hash_scheme, char **salt)
! 1032: {
! 1033: Buffer m;
! 1034:
! 1035: debug3("%s entering", __func__);
! 1036:
! 1037: buffer_init(&m);
! 1038: mm_request_send(pmonitor->m_recvfd,
! 1039: MONITOR_REQ_JPAKE_GET_PWDATA, &m);
! 1040:
! 1041: debug3("%s: waiting for MONITOR_ANS_JPAKE_GET_PWDATA", __func__);
! 1042: mm_request_receive_expect(pmonitor->m_recvfd,
! 1043: MONITOR_ANS_JPAKE_GET_PWDATA, &m);
! 1044:
! 1045: *hash_scheme = buffer_get_string(&m, NULL);
! 1046: *salt = buffer_get_string(&m, NULL);
! 1047:
! 1048: buffer_free(&m);
! 1049: }
! 1050:
! 1051: void
! 1052: mm_jpake_step1(struct jpake_group *grp,
! 1053: u_char **id, u_int *id_len,
! 1054: BIGNUM **priv1, BIGNUM **priv2, BIGNUM **g_priv1, BIGNUM **g_priv2,
! 1055: u_char **priv1_proof, u_int *priv1_proof_len,
! 1056: u_char **priv2_proof, u_int *priv2_proof_len)
! 1057: {
! 1058: Buffer m;
! 1059:
! 1060: debug3("%s entering", __func__);
! 1061:
! 1062: buffer_init(&m);
! 1063: mm_request_send(pmonitor->m_recvfd,
! 1064: MONITOR_REQ_JPAKE_STEP1, &m);
! 1065:
! 1066: debug3("%s: waiting for MONITOR_ANS_JPAKE_STEP1", __func__);
! 1067: mm_request_receive_expect(pmonitor->m_recvfd,
! 1068: MONITOR_ANS_JPAKE_STEP1, &m);
! 1069:
! 1070: if ((*priv1 = BN_new()) == NULL ||
! 1071: (*priv2 = BN_new()) == NULL ||
! 1072: (*g_priv1 = BN_new()) == NULL ||
! 1073: (*g_priv2 = BN_new()) == NULL)
! 1074: fatal("%s: BN_new", __func__);
! 1075:
! 1076: *id = buffer_get_string(&m, id_len);
! 1077: /* priv1 and priv2 are, well, private */
! 1078: buffer_get_bignum2(&m, *g_priv1);
! 1079: buffer_get_bignum2(&m, *g_priv2);
! 1080: *priv1_proof = buffer_get_string(&m, priv1_proof_len);
! 1081: *priv2_proof = buffer_get_string(&m, priv2_proof_len);
! 1082:
! 1083: buffer_free(&m);
! 1084: }
! 1085:
! 1086: void
! 1087: mm_jpake_step2(struct jpake_group *grp, BIGNUM *s,
! 1088: BIGNUM *mypub1, BIGNUM *theirpub1, BIGNUM *theirpub2, BIGNUM *mypriv2,
! 1089: const u_char *theirid, u_int theirid_len,
! 1090: const u_char *myid, u_int myid_len,
! 1091: const u_char *theirpub1_proof, u_int theirpub1_proof_len,
! 1092: const u_char *theirpub2_proof, u_int theirpub2_proof_len,
! 1093: BIGNUM **newpub,
! 1094: u_char **newpub_exponent_proof, u_int *newpub_exponent_proof_len)
! 1095: {
! 1096: Buffer m;
! 1097:
! 1098: debug3("%s entering", __func__);
! 1099:
! 1100: buffer_init(&m);
! 1101: /* monitor already has all bignums except theirpub1, theirpub2 */
! 1102: buffer_put_bignum2(&m, theirpub1);
! 1103: buffer_put_bignum2(&m, theirpub2);
! 1104: /* monitor already knows our id */
! 1105: buffer_put_string(&m, theirid, theirid_len);
! 1106: buffer_put_string(&m, theirpub1_proof, theirpub1_proof_len);
! 1107: buffer_put_string(&m, theirpub2_proof, theirpub2_proof_len);
! 1108:
! 1109: mm_request_send(pmonitor->m_recvfd,
! 1110: MONITOR_REQ_JPAKE_STEP2, &m);
! 1111:
! 1112: debug3("%s: waiting for MONITOR_ANS_JPAKE_STEP2", __func__);
! 1113: mm_request_receive_expect(pmonitor->m_recvfd,
! 1114: MONITOR_ANS_JPAKE_STEP2, &m);
! 1115:
! 1116: if ((*newpub = BN_new()) == NULL)
! 1117: fatal("%s: BN_new", __func__);
! 1118:
! 1119: buffer_get_bignum2(&m, *newpub);
! 1120: *newpub_exponent_proof = buffer_get_string(&m,
! 1121: newpub_exponent_proof_len);
! 1122:
! 1123: buffer_free(&m);
! 1124: }
! 1125:
! 1126: void
! 1127: mm_jpake_key_confirm(struct jpake_group *grp, BIGNUM *s, BIGNUM *step2_val,
! 1128: BIGNUM *mypriv2, BIGNUM *mypub1, BIGNUM *mypub2,
! 1129: BIGNUM *theirpub1, BIGNUM *theirpub2,
! 1130: const u_char *my_id, u_int my_id_len,
! 1131: const u_char *their_id, u_int their_id_len,
! 1132: const u_char *sess_id, u_int sess_id_len,
! 1133: const u_char *theirpriv2_s_proof, u_int theirpriv2_s_proof_len,
! 1134: BIGNUM **k,
! 1135: u_char **confirm_hash, u_int *confirm_hash_len)
! 1136: {
! 1137: Buffer m;
! 1138:
! 1139: debug3("%s entering", __func__);
! 1140:
! 1141: buffer_init(&m);
! 1142: /* monitor already has all bignums except step2_val */
! 1143: buffer_put_bignum2(&m, step2_val);
! 1144: /* monitor already knows all the ids */
! 1145: buffer_put_string(&m, theirpriv2_s_proof, theirpriv2_s_proof_len);
! 1146:
! 1147: mm_request_send(pmonitor->m_recvfd,
! 1148: MONITOR_REQ_JPAKE_KEY_CONFIRM, &m);
! 1149:
! 1150: debug3("%s: waiting for MONITOR_ANS_JPAKE_KEY_CONFIRM", __func__);
! 1151: mm_request_receive_expect(pmonitor->m_recvfd,
! 1152: MONITOR_ANS_JPAKE_KEY_CONFIRM, &m);
! 1153:
! 1154: /* 'k' is sensitive and stays in the monitor */
! 1155: *confirm_hash = buffer_get_string(&m, confirm_hash_len);
! 1156:
! 1157: buffer_free(&m);
! 1158: }
! 1159:
! 1160: int
! 1161: mm_jpake_check_confirm(const BIGNUM *k,
! 1162: const u_char *peer_id, u_int peer_id_len,
! 1163: const u_char *sess_id, u_int sess_id_len,
! 1164: const u_char *peer_confirm_hash, u_int peer_confirm_hash_len)
! 1165: {
! 1166: Buffer m;
! 1167: int success = 0;
! 1168:
! 1169: debug3("%s entering", __func__);
! 1170:
! 1171: buffer_init(&m);
! 1172: /* k is dummy in slave, ignored */
! 1173: /* monitor knows all the ids */
! 1174: buffer_put_string(&m, peer_confirm_hash, peer_confirm_hash_len);
! 1175: mm_request_send(pmonitor->m_recvfd,
! 1176: MONITOR_REQ_JPAKE_CHECK_CONFIRM, &m);
! 1177:
! 1178: debug3("%s: waiting for MONITOR_ANS_JPAKE_CHECK_CONFIRM", __func__);
! 1179: mm_request_receive_expect(pmonitor->m_recvfd,
! 1180: MONITOR_ANS_JPAKE_CHECK_CONFIRM, &m);
! 1181:
! 1182: success = buffer_get_int(&m);
! 1183: buffer_free(&m);
! 1184:
! 1185: debug3("%s: success = %d", __func__, success);
! 1186: return success;
! 1187: }
! 1188: #endif /* JPAKE */