Esempio n. 1
0
int
ed25519_cert_set_ext(ed25519_cert_t *inp, size_t idx, struct ed25519_cert_extension_st * elt)
{
  ed25519_cert_extension_t *oldval = TRUNNEL_DYNARRAY_GET(&inp->ext, idx);
  if (oldval && oldval != elt)
    ed25519_cert_extension_free(oldval);
  return ed25519_cert_set0_ext(inp, idx, elt);
}
Esempio n. 2
0
int
certs_cell_set_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt)
{
  certs_cell_cert_t *oldval = TRUNNEL_DYNARRAY_GET(&inp->certs, idx);
  if (oldval && oldval != elt)
    certs_cell_cert_free(oldval);
  return certs_cell_set0_certs(inp, idx, elt);
}
Esempio n. 3
0
int
trn_cell_introduce_encrypted_set_nspecs(trn_cell_introduce_encrypted_t *inp, size_t idx, struct link_specifier_st * elt)
{
  link_specifier_t *oldval = TRUNNEL_DYNARRAY_GET(&inp->nspecs, idx);
  if (oldval && oldval != elt)
    link_specifier_free(oldval);
  return trn_cell_introduce_encrypted_set0_nspecs(inp, idx, elt);
}
Esempio n. 4
0
/** Release all storage held inside 'obj', but do not free 'obj'.
 */
static void
certs_cell_clear(certs_cell_t *obj)
{
  (void) obj;
  {

    unsigned idx;
    for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->certs); ++idx) {
      certs_cell_cert_free(TRUNNEL_DYNARRAY_GET(&obj->certs, idx));
    }
  }
  TRUNNEL_DYNARRAY_WIPE(&obj->certs);
  TRUNNEL_DYNARRAY_CLEAR(&obj->certs);
}
Esempio n. 5
0
/** Release all storage held inside 'obj', but do not free 'obj'.
 */
static void
ed25519_cert_clear(ed25519_cert_t *obj)
{
  (void) obj;
  {

    unsigned idx;
    for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->ext); ++idx) {
      ed25519_cert_extension_free(TRUNNEL_DYNARRAY_GET(&obj->ext, idx));
    }
  }
  TRUNNEL_DYNARRAY_WIPE(&obj->ext);
  TRUNNEL_DYNARRAY_CLEAR(&obj->ext);
}
Esempio n. 6
0
/** Release all storage held inside 'obj', but do not free 'obj'.
 */
static void
trn_cell_introduce_encrypted_clear(trn_cell_introduce_encrypted_t *obj)
{
  (void) obj;
  trn_cell_extension_free(obj->extensions);
  obj->extensions = NULL;
  TRUNNEL_DYNARRAY_WIPE(&obj->onion_key);
  TRUNNEL_DYNARRAY_CLEAR(&obj->onion_key);
  {

    unsigned idx;
    for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->nspecs); ++idx) {
      link_specifier_free(TRUNNEL_DYNARRAY_GET(&obj->nspecs, idx));
    }
  }
  TRUNNEL_DYNARRAY_WIPE(&obj->nspecs);
  TRUNNEL_DYNARRAY_CLEAR(&obj->nspecs);
  TRUNNEL_DYNARRAY_WIPE(&obj->pad);
  TRUNNEL_DYNARRAY_CLEAR(&obj->pad);
}
Esempio n. 7
0
uint8_t
trn_cell_introduce_encrypted_get_onion_key(trn_cell_introduce_encrypted_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->onion_key, idx);
}
Esempio n. 8
0
uint8_t
trn_cell_introduce1_get_encrypted(trn_cell_introduce1_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->encrypted, idx);
}
Esempio n. 9
0
uint8_t
trn_cell_introduce1_get_auth_key(trn_cell_introduce1_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->auth_key, idx);
}
Esempio n. 10
0
uint8_t
rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->sig, idx);
}
Esempio n. 11
0
uint8_t
certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->body, idx);
}
Esempio n. 12
0
ssize_t
auth_challenge_cell_encode(uint8_t *output, const size_t avail, const auth_challenge_cell_t *obj)
{
  ssize_t result = 0;
  size_t written = 0;
  uint8_t *ptr = output;
  const char *msg;
#ifdef TRUNNEL_CHECK_ENCODED_LEN
  const ssize_t encoded_len = auth_challenge_cell_encoded_len(obj);
#endif

  if (NULL != (msg = auth_challenge_cell_check(obj)))
    goto check_failed;

#ifdef TRUNNEL_CHECK_ENCODED_LEN
  trunnel_assert(encoded_len >= 0);
#endif

  /* Encode u8 challenge[32] */
  trunnel_assert(written <= avail);
  if (avail - written < 32)
    goto truncated;
  memcpy(ptr, obj->challenge, 32);
  written += 32; ptr += 32;

  /* Encode u16 n_methods */
  trunnel_assert(written <= avail);
  if (avail - written < 2)
    goto truncated;
  trunnel_set_uint16(ptr, trunnel_htons(obj->n_methods));
  written += 2; ptr += 2;

  /* Encode u16 methods[n_methods] */
  {

    unsigned idx;
    for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->methods); ++idx) {
      trunnel_assert(written <= avail);
      if (avail - written < 2)
        goto truncated;
      trunnel_set_uint16(ptr, trunnel_htons(TRUNNEL_DYNARRAY_GET(&obj->methods, idx)));
      written += 2; ptr += 2;
    }
  }


  trunnel_assert(ptr == output + written);
#ifdef TRUNNEL_CHECK_ENCODED_LEN
  {
    trunnel_assert(encoded_len >= 0);
    trunnel_assert((size_t)encoded_len == written);
  }

#endif

  return written;

 truncated:
  result = -2;
  goto fail;
 check_failed:
  (void)msg;
  result = -1;
  goto fail;
 fail:
  trunnel_assert(result < 0);
  return result;
}
Esempio n. 13
0
struct ed25519_cert_extension_st *
ed25519_cert_get_ext(ed25519_cert_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->ext, idx);
}
Esempio n. 14
0
struct link_specifier_st *
trn_cell_introduce_encrypted_get_nspecs(trn_cell_introduce_encrypted_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->nspecs, idx);
}
Esempio n. 15
0
uint8_t
auth1_get_sig(auth1_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->sig, idx);
}
Esempio n. 16
0
uint16_t
auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->methods, idx);
}
Esempio n. 17
0
uint8_t
trn_cell_rendezvous1_get_handshake_info(trn_cell_rendezvous1_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->handshake_info, idx);
}
Esempio n. 18
0
File: pwbox.c Progetto: Zensin/tor
uint8_t
pwbox_encoded_get_data(pwbox_encoded_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->data, idx);
}
Esempio n. 19
0
File: pwbox.c Progetto: Zensin/tor
uint8_t
pwbox_encoded_get_skey_header(pwbox_encoded_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->skey_header, idx);
}
Esempio n. 20
0
struct certs_cell_cert_st *
certs_cell_get_certs(certs_cell_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->certs, idx);
}
Esempio n. 21
0
uint8_t
ed25519_cert_extension_get_un_unparsed(ed25519_cert_extension_t *inp, size_t idx)
{
  return TRUNNEL_DYNARRAY_GET(&inp->un_unparsed, idx);
}