Browse Source

Hiding crypt_path_t: Change code to use the privatization macro.

George Kadianakis 5 years ago
parent
commit
ea5f355fc9

+ 7 - 7
src/core/or/crypt_path.c

@@ -112,7 +112,7 @@ cpath_assert_layer_ok(const crypt_path_t *cp)
   switch (cp->state)
     {
     case CPATH_STATE_OPEN:
-      relay_crypto_assert_ok(&cp->private->crypto);
+      relay_crypto_assert_ok(&cp->pvt_crypto);
       /* fall through */
     case CPATH_STATE_CLOSED:
       /*XXXX Assert that there's no handshake_state either. */
@@ -153,7 +153,7 @@ cpath_init_circuit_crypto(crypt_path_t *cpath,
 {
 
   tor_assert(cpath);
-  return relay_crypto_init(&cpath->private->crypto, key_data, key_data_len,
+  return relay_crypto_init(&cpath->pvt_crypto, key_data, key_data_len,
                            reverse, is_hs_v3);
 }
 
@@ -164,7 +164,7 @@ cpath_free(crypt_path_t *victim)
   if (!victim)
     return;
 
-  relay_crypto_clear(&victim->private->crypto);
+  relay_crypto_clear(&victim->pvt_crypto);
   onion_handshake_state_release(&victim->handshake_state);
   crypto_dh_free(victim->rend_dh_handshake_state);
   extend_info_free(victim->extend_info);
@@ -181,9 +181,9 @@ void
 cpath_crypt_cell(const crypt_path_t *cpath, uint8_t *payload, bool is_decrypt)
 {
   if (is_decrypt) {
-    relay_crypt_one_payload(cpath->private->crypto.b_crypto, payload);
+    relay_crypt_one_payload(cpath->pvt_crypto.b_crypto, payload);
   } else {
-    relay_crypt_one_payload(cpath->private->crypto.f_crypto, payload);
+    relay_crypt_one_payload(cpath->pvt_crypto.f_crypto, payload);
   }
 }
 
@@ -191,7 +191,7 @@ cpath_crypt_cell(const crypt_path_t *cpath, uint8_t *payload, bool is_decrypt)
 struct crypto_digest_t *
 cpath_get_incoming_digest(const crypt_path_t *cpath)
 {
-  return cpath->private->crypto.b_digest;
+  return cpath->pvt_crypto.b_digest;
 }
 
 /** Set the right integrity digest on the outgoing <b>cell</b> based on the
@@ -199,7 +199,7 @@ cpath_get_incoming_digest(const crypt_path_t *cpath)
 void
 cpath_set_cell_forward_digest(crypt_path_t *cpath, cell_t *cell)
 {
-  relay_set_digest(cpath->private->crypto.f_digest, cell);
+  relay_set_digest(cpath->pvt_crypto.f_digest, cell);
 }
 
 /************ other cpath functions ***************************/

+ 1 - 1
src/test/test_circuitpadding.c

@@ -150,7 +150,7 @@ new_fake_orcirc(channel_t *nchan, channel_t *pchan)
     log_warn(LD_BUG,"Circuit initialization failed");
     return NULL;
   }
-  orcirc->crypto = tmp_cpath.private->crypto;
+  orcirc->crypto = tmp_cpath.pvt_crypto;
 
   return orcirc;
 }

+ 8 - 8
src/test/test_hs_client.c

@@ -244,13 +244,13 @@ test_e2e_rend_circuit_setup_legacy(void *arg)
 
   /* Check the digest algo */
   tt_int_op(
-         crypto_digest_get_algorithm(or_circ->cpath->private->crypto.f_digest),
+         crypto_digest_get_algorithm(or_circ->cpath->pvt_crypto.f_digest),
             OP_EQ, DIGEST_SHA1);
   tt_int_op(
-         crypto_digest_get_algorithm(or_circ->cpath->private->crypto.b_digest),
+         crypto_digest_get_algorithm(or_circ->cpath->pvt_crypto.b_digest),
             OP_EQ, DIGEST_SHA1);
-  tt_assert(or_circ->cpath->private->crypto.f_crypto);
-  tt_assert(or_circ->cpath->private->crypto.b_crypto);
+  tt_assert(or_circ->cpath->pvt_crypto.f_crypto);
+  tt_assert(or_circ->cpath->pvt_crypto.b_crypto);
 
   /* Ensure that circ purpose was changed */
   tt_int_op(or_circ->base_.purpose, OP_EQ, CIRCUIT_PURPOSE_C_REND_JOINED);
@@ -316,13 +316,13 @@ test_e2e_rend_circuit_setup(void *arg)
 
   /* Check that the crypt path has prop224 algorithm parameters */
   tt_int_op(
-         crypto_digest_get_algorithm(or_circ->cpath->private->crypto.f_digest),
+         crypto_digest_get_algorithm(or_circ->cpath->pvt_crypto.f_digest),
             OP_EQ, DIGEST_SHA3_256);
   tt_int_op(
-         crypto_digest_get_algorithm(or_circ->cpath->private->crypto.b_digest),
+         crypto_digest_get_algorithm(or_circ->cpath->pvt_crypto.b_digest),
             OP_EQ, DIGEST_SHA3_256);
-  tt_assert(or_circ->cpath->private->crypto.f_crypto);
-  tt_assert(or_circ->cpath->private->crypto.b_crypto);
+  tt_assert(or_circ->cpath->pvt_crypto.f_crypto);
+  tt_assert(or_circ->cpath->pvt_crypto.b_crypto);
 
   /* Ensure that circ purpose was changed */
   tt_int_op(or_circ->base_.purpose, OP_EQ, CIRCUIT_PURPOSE_C_REND_JOINED);

+ 4 - 4
src/test/test_hs_service.c

@@ -196,13 +196,13 @@ test_e2e_rend_circuit_setup(void *arg)
 
   /* Check the digest algo */
   tt_int_op(
-         crypto_digest_get_algorithm(or_circ->cpath->private->crypto.f_digest),
+         crypto_digest_get_algorithm(or_circ->cpath->pvt_crypto.f_digest),
             OP_EQ, DIGEST_SHA3_256);
   tt_int_op(
-         crypto_digest_get_algorithm(or_circ->cpath->private->crypto.b_digest),
+         crypto_digest_get_algorithm(or_circ->cpath->pvt_crypto.b_digest),
             OP_EQ, DIGEST_SHA3_256);
-  tt_assert(or_circ->cpath->private->crypto.f_crypto);
-  tt_assert(or_circ->cpath->private->crypto.b_crypto);
+  tt_assert(or_circ->cpath->pvt_crypto.f_crypto);
+  tt_assert(or_circ->cpath->pvt_crypto.b_crypto);
 
   /* Ensure that circ purpose was changed */
   tt_int_op(or_circ->base_.purpose, OP_EQ, CIRCUIT_PURPOSE_S_REND_JOINED);

+ 1 - 1
src/test/test_relaycrypt.c

@@ -51,7 +51,7 @@ testing_circuitset_setup(const struct testcase_t *testcase)
   cs->origin_circ->base_.purpose = CIRCUIT_PURPOSE_C_GENERAL;
   for (i=0; i<3; ++i) {
     crypt_path_t *hop = tor_malloc_zero(sizeof(*hop));
-    relay_crypto_init(&hop->private->crypto, KEY_MATERIAL[i],
+    relay_crypto_init(&hop->pvt_crypto, KEY_MATERIAL[i],
                       sizeof(KEY_MATERIAL[i]), 0, 0);
     hop->state = CPATH_STATE_OPEN;
     cpath_extend_linked_list(&cs->origin_circ->cpath, hop);