diff options
Diffstat (limited to 'monitor_wrap.c')
-rw-r--r-- | monitor_wrap.c | 170 |
1 files changed, 3 insertions, 167 deletions
diff --git a/monitor_wrap.c b/monitor_wrap.c index 670b62dfb..a8fb07b52 100644 --- a/monitor_wrap.c +++ b/monitor_wrap.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor_wrap.c,v 1.77 2013/11/06 16:52:11 markus Exp $ */ | 1 | /* $OpenBSD: monitor_wrap.c,v 1.79 2014/02/02 03:44:31 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> | 3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> |
4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> | 4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> |
@@ -71,8 +71,6 @@ | |||
71 | #include "atomicio.h" | 71 | #include "atomicio.h" |
72 | #include "monitor_fdpass.h" | 72 | #include "monitor_fdpass.h" |
73 | #include "misc.h" | 73 | #include "misc.h" |
74 | #include "schnorr.h" | ||
75 | #include "jpake.h" | ||
76 | #include "uuencode.h" | 74 | #include "uuencode.h" |
77 | 75 | ||
78 | #include "channels.h" | 76 | #include "channels.h" |
@@ -592,7 +590,7 @@ mm_newkeys_to_blob(int mode, u_char **blobp, u_int *lenp) | |||
592 | *blobp = xmalloc(len); | 590 | *blobp = xmalloc(len); |
593 | memcpy(*blobp, buffer_ptr(&b), len); | 591 | memcpy(*blobp, buffer_ptr(&b), len); |
594 | } | 592 | } |
595 | memset(buffer_ptr(&b), 0, len); | 593 | explicit_bzero(buffer_ptr(&b), len); |
596 | buffer_free(&b); | 594 | buffer_free(&b); |
597 | return len; | 595 | return len; |
598 | } | 596 | } |
@@ -636,7 +634,7 @@ mm_send_keystate(struct monitor *monitor) | |||
636 | key = xmalloc(keylen+1); /* add 1 if keylen == 0 */ | 634 | key = xmalloc(keylen+1); /* add 1 if keylen == 0 */ |
637 | keylen = packet_get_encryption_key(key); | 635 | keylen = packet_get_encryption_key(key); |
638 | buffer_put_string(&m, key, keylen); | 636 | buffer_put_string(&m, key, keylen); |
639 | memset(key, 0, keylen); | 637 | explicit_bzero(key, keylen); |
640 | free(key); | 638 | free(key); |
641 | 639 | ||
642 | ivlen = packet_get_keyiv_len(MODE_OUT); | 640 | ivlen = packet_get_keyiv_len(MODE_OUT); |
@@ -1355,168 +1353,6 @@ mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *store) | |||
1355 | 1353 | ||
1356 | #endif /* GSSAPI */ | 1354 | #endif /* GSSAPI */ |
1357 | 1355 | ||
1358 | #ifdef JPAKE | ||
1359 | void | ||
1360 | mm_auth2_jpake_get_pwdata(Authctxt *authctxt, BIGNUM **s, | ||
1361 | char **hash_scheme, char **salt) | ||
1362 | { | ||
1363 | Buffer m; | ||
1364 | |||
1365 | debug3("%s entering", __func__); | ||
1366 | |||
1367 | buffer_init(&m); | ||
1368 | mm_request_send(pmonitor->m_recvfd, | ||
1369 | MONITOR_REQ_JPAKE_GET_PWDATA, &m); | ||
1370 | |||
1371 | debug3("%s: waiting for MONITOR_ANS_JPAKE_GET_PWDATA", __func__); | ||
1372 | mm_request_receive_expect(pmonitor->m_recvfd, | ||
1373 | MONITOR_ANS_JPAKE_GET_PWDATA, &m); | ||
1374 | |||
1375 | *hash_scheme = buffer_get_string(&m, NULL); | ||
1376 | *salt = buffer_get_string(&m, NULL); | ||
1377 | |||
1378 | buffer_free(&m); | ||
1379 | } | ||
1380 | |||
1381 | void | ||
1382 | mm_jpake_step1(struct modp_group *grp, | ||
1383 | u_char **id, u_int *id_len, | ||
1384 | BIGNUM **priv1, BIGNUM **priv2, BIGNUM **g_priv1, BIGNUM **g_priv2, | ||
1385 | u_char **priv1_proof, u_int *priv1_proof_len, | ||
1386 | u_char **priv2_proof, u_int *priv2_proof_len) | ||
1387 | { | ||
1388 | Buffer m; | ||
1389 | |||
1390 | debug3("%s entering", __func__); | ||
1391 | |||
1392 | buffer_init(&m); | ||
1393 | mm_request_send(pmonitor->m_recvfd, | ||
1394 | MONITOR_REQ_JPAKE_STEP1, &m); | ||
1395 | |||
1396 | debug3("%s: waiting for MONITOR_ANS_JPAKE_STEP1", __func__); | ||
1397 | mm_request_receive_expect(pmonitor->m_recvfd, | ||
1398 | MONITOR_ANS_JPAKE_STEP1, &m); | ||
1399 | |||
1400 | if ((*priv1 = BN_new()) == NULL || | ||
1401 | (*priv2 = BN_new()) == NULL || | ||
1402 | (*g_priv1 = BN_new()) == NULL || | ||
1403 | (*g_priv2 = BN_new()) == NULL) | ||
1404 | fatal("%s: BN_new", __func__); | ||
1405 | |||
1406 | *id = buffer_get_string(&m, id_len); | ||
1407 | /* priv1 and priv2 are, well, private */ | ||
1408 | buffer_get_bignum2(&m, *g_priv1); | ||
1409 | buffer_get_bignum2(&m, *g_priv2); | ||
1410 | *priv1_proof = buffer_get_string(&m, priv1_proof_len); | ||
1411 | *priv2_proof = buffer_get_string(&m, priv2_proof_len); | ||
1412 | |||
1413 | buffer_free(&m); | ||
1414 | } | ||
1415 | |||
1416 | void | ||
1417 | mm_jpake_step2(struct modp_group *grp, BIGNUM *s, | ||
1418 | BIGNUM *mypub1, BIGNUM *theirpub1, BIGNUM *theirpub2, BIGNUM *mypriv2, | ||
1419 | const u_char *theirid, u_int theirid_len, | ||
1420 | const u_char *myid, u_int myid_len, | ||
1421 | const u_char *theirpub1_proof, u_int theirpub1_proof_len, | ||
1422 | const u_char *theirpub2_proof, u_int theirpub2_proof_len, | ||
1423 | BIGNUM **newpub, | ||
1424 | u_char **newpub_exponent_proof, u_int *newpub_exponent_proof_len) | ||
1425 | { | ||
1426 | Buffer m; | ||
1427 | |||
1428 | debug3("%s entering", __func__); | ||
1429 | |||
1430 | buffer_init(&m); | ||
1431 | /* monitor already has all bignums except theirpub1, theirpub2 */ | ||
1432 | buffer_put_bignum2(&m, theirpub1); | ||
1433 | buffer_put_bignum2(&m, theirpub2); | ||
1434 | /* monitor already knows our id */ | ||
1435 | buffer_put_string(&m, theirid, theirid_len); | ||
1436 | buffer_put_string(&m, theirpub1_proof, theirpub1_proof_len); | ||
1437 | buffer_put_string(&m, theirpub2_proof, theirpub2_proof_len); | ||
1438 | |||
1439 | mm_request_send(pmonitor->m_recvfd, | ||
1440 | MONITOR_REQ_JPAKE_STEP2, &m); | ||
1441 | |||
1442 | debug3("%s: waiting for MONITOR_ANS_JPAKE_STEP2", __func__); | ||
1443 | mm_request_receive_expect(pmonitor->m_recvfd, | ||
1444 | MONITOR_ANS_JPAKE_STEP2, &m); | ||
1445 | |||
1446 | if ((*newpub = BN_new()) == NULL) | ||
1447 | fatal("%s: BN_new", __func__); | ||
1448 | |||
1449 | buffer_get_bignum2(&m, *newpub); | ||
1450 | *newpub_exponent_proof = buffer_get_string(&m, | ||
1451 | newpub_exponent_proof_len); | ||
1452 | |||
1453 | buffer_free(&m); | ||
1454 | } | ||
1455 | |||
1456 | void | ||
1457 | mm_jpake_key_confirm(struct modp_group *grp, BIGNUM *s, BIGNUM *step2_val, | ||
1458 | BIGNUM *mypriv2, BIGNUM *mypub1, BIGNUM *mypub2, | ||
1459 | BIGNUM *theirpub1, BIGNUM *theirpub2, | ||
1460 | const u_char *my_id, u_int my_id_len, | ||
1461 | const u_char *their_id, u_int their_id_len, | ||
1462 | const u_char *sess_id, u_int sess_id_len, | ||
1463 | const u_char *theirpriv2_s_proof, u_int theirpriv2_s_proof_len, | ||
1464 | BIGNUM **k, | ||
1465 | u_char **confirm_hash, u_int *confirm_hash_len) | ||
1466 | { | ||
1467 | Buffer m; | ||
1468 | |||
1469 | debug3("%s entering", __func__); | ||
1470 | |||
1471 | buffer_init(&m); | ||
1472 | /* monitor already has all bignums except step2_val */ | ||
1473 | buffer_put_bignum2(&m, step2_val); | ||
1474 | /* monitor already knows all the ids */ | ||
1475 | buffer_put_string(&m, theirpriv2_s_proof, theirpriv2_s_proof_len); | ||
1476 | |||
1477 | mm_request_send(pmonitor->m_recvfd, | ||
1478 | MONITOR_REQ_JPAKE_KEY_CONFIRM, &m); | ||
1479 | |||
1480 | debug3("%s: waiting for MONITOR_ANS_JPAKE_KEY_CONFIRM", __func__); | ||
1481 | mm_request_receive_expect(pmonitor->m_recvfd, | ||
1482 | MONITOR_ANS_JPAKE_KEY_CONFIRM, &m); | ||
1483 | |||
1484 | /* 'k' is sensitive and stays in the monitor */ | ||
1485 | *confirm_hash = buffer_get_string(&m, confirm_hash_len); | ||
1486 | |||
1487 | buffer_free(&m); | ||
1488 | } | ||
1489 | |||
1490 | int | ||
1491 | mm_jpake_check_confirm(const BIGNUM *k, | ||
1492 | const u_char *peer_id, u_int peer_id_len, | ||
1493 | const u_char *sess_id, u_int sess_id_len, | ||
1494 | const u_char *peer_confirm_hash, u_int peer_confirm_hash_len) | ||
1495 | { | ||
1496 | Buffer m; | ||
1497 | int success = 0; | ||
1498 | |||
1499 | debug3("%s entering", __func__); | ||
1500 | |||
1501 | buffer_init(&m); | ||
1502 | /* k is dummy in slave, ignored */ | ||
1503 | /* monitor knows all the ids */ | ||
1504 | buffer_put_string(&m, peer_confirm_hash, peer_confirm_hash_len); | ||
1505 | mm_request_send(pmonitor->m_recvfd, | ||
1506 | MONITOR_REQ_JPAKE_CHECK_CONFIRM, &m); | ||
1507 | |||
1508 | debug3("%s: waiting for MONITOR_ANS_JPAKE_CHECK_CONFIRM", __func__); | ||
1509 | mm_request_receive_expect(pmonitor->m_recvfd, | ||
1510 | MONITOR_ANS_JPAKE_CHECK_CONFIRM, &m); | ||
1511 | |||
1512 | success = buffer_get_int(&m); | ||
1513 | buffer_free(&m); | ||
1514 | |||
1515 | debug3("%s: success = %d", __func__, success); | ||
1516 | return success; | ||
1517 | } | ||
1518 | #endif /* JPAKE */ | ||
1519 | |||
1520 | #ifdef USE_CONSOLEKIT | 1356 | #ifdef USE_CONSOLEKIT |
1521 | char * | 1357 | char * |
1522 | mm_consolekit_register(Session *s, const char *display) | 1358 | mm_consolekit_register(Session *s, const char *display) |