diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/net_crypto.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c index 1803caba..f0bce738 100644 --- a/core/net_crypto.c +++ b/core/net_crypto.c | |||
@@ -467,7 +467,6 @@ int accept_crypto_inbound(int connection_id, uint8_t *public_key, uint8_t *secre | |||
467 | random_nonce(crypto_connections[i].recv_nonce); | 467 | random_nonce(crypto_connections[i].recv_nonce); |
468 | memcpy(crypto_connections[i].sent_nonce, secret_nonce, crypto_box_NONCEBYTES); | 468 | memcpy(crypto_connections[i].sent_nonce, secret_nonce, crypto_box_NONCEBYTES); |
469 | memcpy(crypto_connections[i].peersessionpublic_key, session_key, crypto_box_PUBLICKEYBYTES); | 469 | memcpy(crypto_connections[i].peersessionpublic_key, session_key, crypto_box_PUBLICKEYBYTES); |
470 | |||
471 | increment_nonce(crypto_connections[i].sent_nonce); | 470 | increment_nonce(crypto_connections[i].sent_nonce); |
472 | memcpy(crypto_connections[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); | 471 | memcpy(crypto_connections[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); |
473 | 472 | ||
@@ -477,6 +476,9 @@ int accept_crypto_inbound(int connection_id, uint8_t *public_key, uint8_t *secre | |||
477 | crypto_connections[i].sessionpublic_key) == 1) { | 476 | crypto_connections[i].sessionpublic_key) == 1) { |
478 | increment_nonce(crypto_connections[i].recv_nonce); | 477 | increment_nonce(crypto_connections[i].recv_nonce); |
479 | uint32_t zero = 0; | 478 | uint32_t zero = 0; |
479 | encrypt_precompute(crypto_connections[i].peersessionpublic_key, | ||
480 | crypto_connections[i].sessionsecret_key, | ||
481 | crypto_connections[i].shared_key); | ||
480 | crypto_connections[i].status = CONN_ESTABLISHED; /* connection status needs to be 3 for write_cryptpacket() to work */ | 482 | crypto_connections[i].status = CONN_ESTABLISHED; /* connection status needs to be 3 for write_cryptpacket() to work */ |
481 | write_cryptpacket(i, ((uint8_t *)&zero), sizeof(zero)); | 483 | write_cryptpacket(i, ((uint8_t *)&zero), sizeof(zero)); |
482 | crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */ | 484 | crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */ |
@@ -569,9 +571,11 @@ static void receive_crypto(void) | |||
569 | if (memcmp(public_key, crypto_connections[i].public_key, crypto_box_PUBLICKEYBYTES) == 0) { | 571 | if (memcmp(public_key, crypto_connections[i].public_key, crypto_box_PUBLICKEYBYTES) == 0) { |
570 | memcpy(crypto_connections[i].sent_nonce, secret_nonce, crypto_box_NONCEBYTES); | 572 | memcpy(crypto_connections[i].sent_nonce, secret_nonce, crypto_box_NONCEBYTES); |
571 | memcpy(crypto_connections[i].peersessionpublic_key, session_key, crypto_box_PUBLICKEYBYTES); | 573 | memcpy(crypto_connections[i].peersessionpublic_key, session_key, crypto_box_PUBLICKEYBYTES); |
572 | encrypt_precompute(crypto_connections[i].peersessionpublic_key, crypto_connections[i].sessionsecret_key, crypto_connections[i].shared_key); | ||
573 | increment_nonce(crypto_connections[i].sent_nonce); | 574 | increment_nonce(crypto_connections[i].sent_nonce); |
574 | uint32_t zero = 0; | 575 | uint32_t zero = 0; |
576 | encrypt_precompute(crypto_connections[i].peersessionpublic_key, | ||
577 | crypto_connections[i].sessionsecret_key, | ||
578 | crypto_connections[i].shared_key); | ||
575 | crypto_connections[i].status = CONN_ESTABLISHED; /* connection status needs to be 3 for write_cryptpacket() to work */ | 579 | crypto_connections[i].status = CONN_ESTABLISHED; /* connection status needs to be 3 for write_cryptpacket() to work */ |
576 | write_cryptpacket(i, ((uint8_t *)&zero), sizeof(zero)); | 580 | write_cryptpacket(i, ((uint8_t *)&zero), sizeof(zero)); |
577 | crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */ | 581 | crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */ |
@@ -592,6 +596,9 @@ static void receive_crypto(void) | |||
592 | uint32_t zero = 0; | 596 | uint32_t zero = 0; |
593 | if (len == sizeof(uint32_t) && memcmp(((uint8_t *)&zero), data, sizeof(uint32_t)) == 0) { | 597 | if (len == sizeof(uint32_t) && memcmp(((uint8_t *)&zero), data, sizeof(uint32_t)) == 0) { |
594 | increment_nonce(crypto_connections[i].recv_nonce); | 598 | increment_nonce(crypto_connections[i].recv_nonce); |
599 | encrypt_precompute(crypto_connections[i].peersessionpublic_key, | ||
600 | crypto_connections[i].sessionsecret_key, | ||
601 | crypto_connections[i].shared_key); | ||
595 | crypto_connections[i].status = CONN_ESTABLISHED; | 602 | crypto_connections[i].status = CONN_ESTABLISHED; |
596 | 603 | ||
597 | /* connection is accepted so we disable the auto kill by setting it to about 1 month from now. */ | 604 | /* connection is accepted so we disable the auto kill by setting it to about 1 month from now. */ |