Commit 79cfe2dd authored by David Goulet's avatar David Goulet 🐼 Committed by Nick Mathewson
Browse files

hs: Remove hs_intro_auth_key_type_t enum



Like the previous commit about the INTRODUCE_ACK status code, change all auth
key type to use the one defined in the trunnel file.

Standardize the use of these auth type to a common ABI.

Part of #30454

Signed-off-by: David Goulet's avatarDavid Goulet <dgoulet@torproject.org>
parent dcc1d8d1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -441,7 +441,8 @@ introduce1_set_auth_key(trn_cell_introduce1_t *cell,
  tor_assert(cell);
  tor_assert(data);
  /* There is only one possible type for a non legacy cell. */
  trn_cell_introduce1_set_auth_key_type(cell, HS_INTRO_AUTH_KEY_TYPE_ED25519);
  trn_cell_introduce1_set_auth_key_type(cell,
                                   TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519);
  trn_cell_introduce1_set_auth_key_len(cell, ED25519_PUBKEY_LEN);
  trn_cell_introduce1_setlen_auth_key(cell, ED25519_PUBKEY_LEN);
  memcpy(trn_cell_introduce1_getarray_auth_key(cell),
@@ -514,7 +515,7 @@ hs_cell_build_establish_intro(const char *circ_nonce,

  /* Set AUTH_KEY_TYPE: 2 means ed25519 */
  trn_cell_establish_intro_set_auth_key_type(cell,
                                             HS_INTRO_AUTH_KEY_TYPE_ED25519);
                                    TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519);

  /* Set AUTH_KEY and AUTH_KEY_LEN field. Must also set byte-length of
   * AUTH_KEY to match */
+5 −5
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ verify_establish_intro_cell(const trn_cell_establish_intro_t *cell,
  /* We only reach this function if the first byte of the cell is 0x02 which
   * means that auth_key_type is of ed25519 type, hence this check should
   * always pass. See hs_intro_received_establish_intro().  */
  if (BUG(cell->auth_key_type != HS_INTRO_AUTH_KEY_TYPE_ED25519)) {
  if (BUG(cell->auth_key_type != TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519)) {
    return -1;
  }

@@ -315,10 +315,10 @@ hs_intro_received_establish_intro(or_circuit_t *circ, const uint8_t *request,
   * ESTABLISH_INTRO and pass it to the appropriate cell handler */
  const uint8_t first_byte = request[0];
  switch (first_byte) {
    case HS_INTRO_AUTH_KEY_TYPE_LEGACY0:
    case HS_INTRO_AUTH_KEY_TYPE_LEGACY1:
    case TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY0:
    case TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY1:
      return rend_mid_establish_intro_legacy(circ, request, request_len);
    case HS_INTRO_AUTH_KEY_TYPE_ED25519:
    case TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519:
      return handle_establish_intro(circ, request, request_len);
    default:
      log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
@@ -396,7 +396,7 @@ validate_introduce1_parsed_cell(const trn_cell_introduce1_t *cell)
  /* The auth key of an INTRODUCE1 should be of type ed25519 thus leading to a
   * known fixed length as well. */
  if (trn_cell_introduce1_get_auth_key_type(cell) !=
      HS_INTRO_AUTH_KEY_TYPE_ED25519) {
      TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519) {
    log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
           "Rejecting invalid INTRODUCE1 cell auth key type. "
           "Responding with NACK.");
+0 −7
Original line number Diff line number Diff line
@@ -12,13 +12,6 @@
#include "crypto_curve25519.h"
#include "torcert.h"

/* Authentication key type in an ESTABLISH_INTRO cell. */
typedef enum {
  HS_INTRO_AUTH_KEY_TYPE_LEGACY0 = 0x00,
  HS_INTRO_AUTH_KEY_TYPE_LEGACY1 = 0x01,
  HS_INTRO_AUTH_KEY_TYPE_ED25519 = 0x02,
} hs_intro_auth_key_type_t;

/* Object containing introduction point common data between the service and
 * the client side. */
typedef struct hs_intropoint_t {
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ test_gen_establish_intro_cell(void *arg)
  /* Check the contents of the cell */
  {
    /* First byte is the auth key type: make sure its correct */
    tt_int_op(buf[0], OP_EQ, HS_INTRO_AUTH_KEY_TYPE_ED25519);
    tt_int_op(buf[0], OP_EQ, TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519);
    /* Next two bytes is auth key len */
    tt_int_op(ntohs(get_uint16(buf+1)), OP_EQ, ED25519_PUBKEY_LEN);
    /* Skip to the number of extensions: no extensions */
+2 −2
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ helper_create_introduce1_cell(void)
  {
    size_t auth_key_len = sizeof(auth_key_kp.pubkey);
    trn_cell_introduce1_set_auth_key_type(cell,
                                         HS_INTRO_AUTH_KEY_TYPE_ED25519);
                                     TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519);
    trn_cell_introduce1_set_auth_key_len(cell, auth_key_len);
    trn_cell_introduce1_setlen_auth_key(cell, auth_key_len);
    uint8_t *auth_key_ptr = trn_cell_introduce1_getarray_auth_key(cell);
@@ -749,7 +749,7 @@ test_introduce1_validation(void *arg)
  ret = validate_introduce1_parsed_cell(cell);
  tt_int_op(ret, OP_EQ, -1);
  /* Reset is to correct value and make sure it's correct. */
  cell->auth_key_type = HS_INTRO_AUTH_KEY_TYPE_ED25519;
  cell->auth_key_type = TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519;
  ret = validate_introduce1_parsed_cell(cell);
  tt_int_op(ret, OP_EQ, 0);

Loading