summaryrefslogtreecommitdiff
path: root/src/trunnel
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-06-26 19:31:26 +0300
committerNick Mathewson <nickm@torproject.org>2018-07-12 11:41:44 -0400
commitf27dc41627517ebec3feae6ca00eee544d9dcd59 (patch)
tree1cec7e5429db3a9edb648dc245a8735338a4bffb /src/trunnel
parent2f284d3325f60ad4e4744504588ee62dd62779e9 (diff)
downloadtor-f27dc41627517ebec3feae6ca00eee544d9dcd59.tar.gz
tor-f27dc41627517ebec3feae6ca00eee544d9dcd59.zip
Remove prop229 stuff from socks5.trunnel
Diffstat (limited to 'src/trunnel')
-rw-r--r--src/trunnel/socks5.c1076
-rw-r--r--src/trunnel/socks5.h376
-rw-r--r--src/trunnel/socks5.trunnel22
3 files changed, 0 insertions, 1474 deletions
diff --git a/src/trunnel/socks5.c b/src/trunnel/socks5.c
index 7f4702fb5d..9e5f6fcfed 100644
--- a/src/trunnel/socks5.c
+++ b/src/trunnel/socks5.c
@@ -3029,400 +3029,6 @@ socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const
}
return result;
}
-tor_socksauth_keyval_t *
-tor_socksauth_keyval_new(void)
-{
- tor_socksauth_keyval_t *val = trunnel_calloc(1, sizeof(tor_socksauth_keyval_t));
- if (NULL == val)
- return NULL;
- return val;
-}
-
-/** Release all storage held inside 'obj', but do not free 'obj'.
- */
-static void
-tor_socksauth_keyval_clear(tor_socksauth_keyval_t *obj)
-{
- (void) obj;
- TRUNNEL_DYNARRAY_WIPE(&obj->key);
- TRUNNEL_DYNARRAY_CLEAR(&obj->key);
- TRUNNEL_DYNARRAY_WIPE(&obj->val);
- TRUNNEL_DYNARRAY_CLEAR(&obj->val);
-}
-
-void
-tor_socksauth_keyval_free(tor_socksauth_keyval_t *obj)
-{
- if (obj == NULL)
- return;
- tor_socksauth_keyval_clear(obj);
- trunnel_memwipe(obj, sizeof(tor_socksauth_keyval_t));
- trunnel_free_(obj);
-}
-
-uint16_t
-tor_socksauth_keyval_get_keylen(const tor_socksauth_keyval_t *inp)
-{
- return inp->keylen;
-}
-int
-tor_socksauth_keyval_set_keylen(tor_socksauth_keyval_t *inp, uint16_t val)
-{
- inp->keylen = val;
- return 0;
-}
-size_t
-tor_socksauth_keyval_getlen_key(const tor_socksauth_keyval_t *inp)
-{
- return TRUNNEL_DYNARRAY_LEN(&inp->key);
-}
-
-char
-tor_socksauth_keyval_get_key(tor_socksauth_keyval_t *inp, size_t idx)
-{
- return TRUNNEL_DYNARRAY_GET(&inp->key, idx);
-}
-
-char
-tor_socksauth_keyval_getconst_key(const tor_socksauth_keyval_t *inp, size_t idx)
-{
- return tor_socksauth_keyval_get_key((tor_socksauth_keyval_t*)inp, idx);
-}
-int
-tor_socksauth_keyval_set_key(tor_socksauth_keyval_t *inp, size_t idx, char elt)
-{
- TRUNNEL_DYNARRAY_SET(&inp->key, idx, elt);
- return 0;
-}
-int
-tor_socksauth_keyval_add_key(tor_socksauth_keyval_t *inp, char elt)
-{
-#if SIZE_MAX >= UINT16_MAX
- if (inp->key.n_ == UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- TRUNNEL_DYNARRAY_ADD(char, &inp->key, elt, {});
- return 0;
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-
-char *
-tor_socksauth_keyval_getarray_key(tor_socksauth_keyval_t *inp)
-{
- return inp->key.elts_;
-}
-const char *
-tor_socksauth_keyval_getconstarray_key(const tor_socksauth_keyval_t *inp)
-{
- return (const char *)tor_socksauth_keyval_getarray_key((tor_socksauth_keyval_t*)inp);
-}
-int
-tor_socksauth_keyval_setlen_key(tor_socksauth_keyval_t *inp, size_t newlen)
-{
-#if UINT16_MAX < SIZE_MAX
- if (newlen > UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- return trunnel_string_setlen(&inp->key, newlen,
- &inp->trunnel_error_code_);
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-const char *
-tor_socksauth_keyval_getstr_key(tor_socksauth_keyval_t *inp)
-{
- return trunnel_string_getstr(&inp->key);
-}
-int
-tor_socksauth_keyval_setstr0_key(tor_socksauth_keyval_t *inp, const char *val, size_t len)
-{
-#if UINT16_MAX < SIZE_MAX
- if (len > UINT16_MAX) {
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
- }
-#endif
- return trunnel_string_setstr0(&inp->key, val, len, &inp->trunnel_error_code_);
-}
-int
-tor_socksauth_keyval_setstr_key(tor_socksauth_keyval_t *inp, const char *val)
-{
- return tor_socksauth_keyval_setstr0_key(inp, val, strlen(val));
-}
-uint16_t
-tor_socksauth_keyval_get_vallen(const tor_socksauth_keyval_t *inp)
-{
- return inp->vallen;
-}
-int
-tor_socksauth_keyval_set_vallen(tor_socksauth_keyval_t *inp, uint16_t val)
-{
- inp->vallen = val;
- return 0;
-}
-size_t
-tor_socksauth_keyval_getlen_val(const tor_socksauth_keyval_t *inp)
-{
- return TRUNNEL_DYNARRAY_LEN(&inp->val);
-}
-
-char
-tor_socksauth_keyval_get_val(tor_socksauth_keyval_t *inp, size_t idx)
-{
- return TRUNNEL_DYNARRAY_GET(&inp->val, idx);
-}
-
-char
-tor_socksauth_keyval_getconst_val(const tor_socksauth_keyval_t *inp, size_t idx)
-{
- return tor_socksauth_keyval_get_val((tor_socksauth_keyval_t*)inp, idx);
-}
-int
-tor_socksauth_keyval_set_val(tor_socksauth_keyval_t *inp, size_t idx, char elt)
-{
- TRUNNEL_DYNARRAY_SET(&inp->val, idx, elt);
- return 0;
-}
-int
-tor_socksauth_keyval_add_val(tor_socksauth_keyval_t *inp, char elt)
-{
-#if SIZE_MAX >= UINT16_MAX
- if (inp->val.n_ == UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- TRUNNEL_DYNARRAY_ADD(char, &inp->val, elt, {});
- return 0;
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-
-char *
-tor_socksauth_keyval_getarray_val(tor_socksauth_keyval_t *inp)
-{
- return inp->val.elts_;
-}
-const char *
-tor_socksauth_keyval_getconstarray_val(const tor_socksauth_keyval_t *inp)
-{
- return (const char *)tor_socksauth_keyval_getarray_val((tor_socksauth_keyval_t*)inp);
-}
-int
-tor_socksauth_keyval_setlen_val(tor_socksauth_keyval_t *inp, size_t newlen)
-{
-#if UINT16_MAX < SIZE_MAX
- if (newlen > UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- return trunnel_string_setlen(&inp->val, newlen,
- &inp->trunnel_error_code_);
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-const char *
-tor_socksauth_keyval_getstr_val(tor_socksauth_keyval_t *inp)
-{
- return trunnel_string_getstr(&inp->val);
-}
-int
-tor_socksauth_keyval_setstr0_val(tor_socksauth_keyval_t *inp, const char *val, size_t len)
-{
-#if UINT16_MAX < SIZE_MAX
- if (len > UINT16_MAX) {
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
- }
-#endif
- return trunnel_string_setstr0(&inp->val, val, len, &inp->trunnel_error_code_);
-}
-int
-tor_socksauth_keyval_setstr_val(tor_socksauth_keyval_t *inp, const char *val)
-{
- return tor_socksauth_keyval_setstr0_val(inp, val, strlen(val));
-}
-const char *
-tor_socksauth_keyval_check(const tor_socksauth_keyval_t *obj)
-{
- if (obj == NULL)
- return "Object was NULL";
- if (obj->trunnel_error_code_)
- return "A set function failed on this object";
- if (TRUNNEL_DYNARRAY_LEN(&obj->key) != obj->keylen)
- return "Length mismatch for key";
- if (TRUNNEL_DYNARRAY_LEN(&obj->val) != obj->vallen)
- return "Length mismatch for val";
- return NULL;
-}
-
-ssize_t
-tor_socksauth_keyval_encoded_len(const tor_socksauth_keyval_t *obj)
-{
- ssize_t result = 0;
-
- if (NULL != tor_socksauth_keyval_check(obj))
- return -1;
-
-
- /* Length of u16 keylen */
- result += 2;
-
- /* Length of char key[keylen] */
- result += TRUNNEL_DYNARRAY_LEN(&obj->key);
-
- /* Length of u16 vallen */
- result += 2;
-
- /* Length of char val[vallen] */
- result += TRUNNEL_DYNARRAY_LEN(&obj->val);
- return result;
-}
-int
-tor_socksauth_keyval_clear_errors(tor_socksauth_keyval_t *obj)
-{
- int r = obj->trunnel_error_code_;
- obj->trunnel_error_code_ = 0;
- return r;
-}
-ssize_t
-tor_socksauth_keyval_encode(uint8_t *output, const size_t avail, const tor_socksauth_keyval_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 = tor_socksauth_keyval_encoded_len(obj);
-#endif
-
- if (NULL != (msg = tor_socksauth_keyval_check(obj)))
- goto check_failed;
-
-#ifdef TRUNNEL_CHECK_ENCODED_LEN
- trunnel_assert(encoded_len >= 0);
-#endif
-
- /* Encode u16 keylen */
- trunnel_assert(written <= avail);
- if (avail - written < 2)
- goto truncated;
- trunnel_set_uint16(ptr, trunnel_htons(obj->keylen));
- written += 2; ptr += 2;
-
- /* Encode char key[keylen] */
- {
- size_t elt_len = TRUNNEL_DYNARRAY_LEN(&obj->key);
- trunnel_assert(obj->keylen == elt_len);
- trunnel_assert(written <= avail);
- if (avail - written < elt_len)
- goto truncated;
- if (elt_len)
- memcpy(ptr, obj->key.elts_, elt_len);
- written += elt_len; ptr += elt_len;
- }
-
- /* Encode u16 vallen */
- trunnel_assert(written <= avail);
- if (avail - written < 2)
- goto truncated;
- trunnel_set_uint16(ptr, trunnel_htons(obj->vallen));
- written += 2; ptr += 2;
-
- /* Encode char val[vallen] */
- {
- size_t elt_len = TRUNNEL_DYNARRAY_LEN(&obj->val);
- trunnel_assert(obj->vallen == elt_len);
- trunnel_assert(written <= avail);
- if (avail - written < elt_len)
- goto truncated;
- if (elt_len)
- memcpy(ptr, obj->val.elts_, elt_len);
- written += elt_len; ptr += elt_len;
- }
-
-
- 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;
-}
-
-/** As tor_socksauth_keyval_parse(), but do not allocate the output
- * object.
- */
-static ssize_t
-tor_socksauth_keyval_parse_into(tor_socksauth_keyval_t *obj, const uint8_t *input, const size_t len_in)
-{
- const uint8_t *ptr = input;
- size_t remaining = len_in;
- ssize_t result = 0;
- (void)result;
-
- /* Parse u16 keylen */
- CHECK_REMAINING(2, truncated);
- obj->keylen = trunnel_ntohs(trunnel_get_uint16(ptr));
- remaining -= 2; ptr += 2;
-
- /* Parse char key[keylen] */
- CHECK_REMAINING(obj->keylen, truncated);
- if (tor_socksauth_keyval_setstr0_key(obj, (const char*)ptr, obj->keylen))
- goto fail;
- ptr += obj->keylen; remaining -= obj->keylen;
-
- /* Parse u16 vallen */
- CHECK_REMAINING(2, truncated);
- obj->vallen = trunnel_ntohs(trunnel_get_uint16(ptr));
- remaining -= 2; ptr += 2;
-
- /* Parse char val[vallen] */
- CHECK_REMAINING(obj->vallen, truncated);
- if (tor_socksauth_keyval_setstr0_val(obj, (const char*)ptr, obj->vallen))
- goto fail;
- ptr += obj->vallen; remaining -= obj->vallen;
- trunnel_assert(ptr + remaining == input + len_in);
- return len_in - remaining;
-
- truncated:
- return -2;
- fail:
- result = -1;
- return result;
-}
-
-ssize_t
-tor_socksauth_keyval_parse(tor_socksauth_keyval_t **output, const uint8_t *input, const size_t len_in)
-{
- ssize_t result;
- *output = tor_socksauth_keyval_new();
- if (NULL == *output)
- return -1;
- result = tor_socksauth_keyval_parse_into(*output, input, len_in);
- if (result < 0) {
- tor_socksauth_keyval_free(*output);
- *output = NULL;
- }
- return result;
-}
socks5_client_request_t *
socks5_client_request_new(void)
{
@@ -4370,685 +3976,3 @@ socks5_server_reply_parse(socks5_server_reply_t **output, const uint8_t *input,
}
return result;
}
-tor_extended_socks_auth_request_t *
-tor_extended_socks_auth_request_new(void)
-{
- tor_extended_socks_auth_request_t *val = trunnel_calloc(1, sizeof(tor_extended_socks_auth_request_t));
- if (NULL == val)
- return NULL;
- val->version = 1;
- return val;
-}
-
-/** Release all storage held inside 'obj', but do not free 'obj'.
- */
-static void
-tor_extended_socks_auth_request_clear(tor_extended_socks_auth_request_t *obj)
-{
- (void) obj;
- {
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- tor_socksauth_keyval_free(TRUNNEL_DYNARRAY_GET(&obj->pairs, idx));
- }
- }
- TRUNNEL_DYNARRAY_WIPE(&obj->pairs);
- TRUNNEL_DYNARRAY_CLEAR(&obj->pairs);
-}
-
-void
-tor_extended_socks_auth_request_free(tor_extended_socks_auth_request_t *obj)
-{
- if (obj == NULL)
- return;
- tor_extended_socks_auth_request_clear(obj);
- trunnel_memwipe(obj, sizeof(tor_extended_socks_auth_request_t));
- trunnel_free_(obj);
-}
-
-uint8_t
-tor_extended_socks_auth_request_get_version(const tor_extended_socks_auth_request_t *inp)
-{
- return inp->version;
-}
-int
-tor_extended_socks_auth_request_set_version(tor_extended_socks_auth_request_t *inp, uint8_t val)
-{
- if (! ((val == 1))) {
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
- }
- inp->version = val;
- return 0;
-}
-uint16_t
-tor_extended_socks_auth_request_get_npairs(const tor_extended_socks_auth_request_t *inp)
-{
- return inp->npairs;
-}
-int
-tor_extended_socks_auth_request_set_npairs(tor_extended_socks_auth_request_t *inp, uint16_t val)
-{
- inp->npairs = val;
- return 0;
-}
-size_t
-tor_extended_socks_auth_request_getlen_pairs(const tor_extended_socks_auth_request_t *inp)
-{
- return TRUNNEL_DYNARRAY_LEN(&inp->pairs);
-}
-
-struct tor_socksauth_keyval_st *
-tor_extended_socks_auth_request_get_pairs(tor_extended_socks_auth_request_t *inp, size_t idx)
-{
- return TRUNNEL_DYNARRAY_GET(&inp->pairs, idx);
-}
-
- const struct tor_socksauth_keyval_st *
-tor_extended_socks_auth_request_getconst_pairs(const tor_extended_socks_auth_request_t *inp, size_t idx)
-{
- return tor_extended_socks_auth_request_get_pairs((tor_extended_socks_auth_request_t*)inp, idx);
-}
-int
-tor_extended_socks_auth_request_set_pairs(tor_extended_socks_auth_request_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt)
-{
- tor_socksauth_keyval_t *oldval = TRUNNEL_DYNARRAY_GET(&inp->pairs, idx);
- if (oldval && oldval != elt)
- tor_socksauth_keyval_free(oldval);
- return tor_extended_socks_auth_request_set0_pairs(inp, idx, elt);
-}
-int
-tor_extended_socks_auth_request_set0_pairs(tor_extended_socks_auth_request_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt)
-{
- TRUNNEL_DYNARRAY_SET(&inp->pairs, idx, elt);
- return 0;
-}
-int
-tor_extended_socks_auth_request_add_pairs(tor_extended_socks_auth_request_t *inp, struct tor_socksauth_keyval_st * elt)
-{
-#if SIZE_MAX >= UINT16_MAX
- if (inp->pairs.n_ == UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- TRUNNEL_DYNARRAY_ADD(struct tor_socksauth_keyval_st *, &inp->pairs, elt, {});
- return 0;
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-
-struct tor_socksauth_keyval_st * *
-tor_extended_socks_auth_request_getarray_pairs(tor_extended_socks_auth_request_t *inp)
-{
- return inp->pairs.elts_;
-}
-const struct tor_socksauth_keyval_st * const *
-tor_extended_socks_auth_request_getconstarray_pairs(const tor_extended_socks_auth_request_t *inp)
-{
- return (const struct tor_socksauth_keyval_st * const *)tor_extended_socks_auth_request_getarray_pairs((tor_extended_socks_auth_request_t*)inp);
-}
-int
-tor_extended_socks_auth_request_setlen_pairs(tor_extended_socks_auth_request_t *inp, size_t newlen)
-{
- struct tor_socksauth_keyval_st * *newptr;
-#if UINT16_MAX < SIZE_MAX
- if (newlen > UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- newptr = trunnel_dynarray_setlen(&inp->pairs.allocated_,
- &inp->pairs.n_, inp->pairs.elts_, newlen,
- sizeof(inp->pairs.elts_[0]), (trunnel_free_fn_t) tor_socksauth_keyval_free,
- &inp->trunnel_error_code_);
- if (newlen != 0 && newptr == NULL)
- goto trunnel_alloc_failed;
- inp->pairs.elts_ = newptr;
- return 0;
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-const char *
-tor_extended_socks_auth_request_check(const tor_extended_socks_auth_request_t *obj)
-{
- if (obj == NULL)
- return "Object was NULL";
- if (obj->trunnel_error_code_)
- return "A set function failed on this object";
- if (! (obj->version == 1))
- return "Integer out of bounds";
- {
- const char *msg;
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- if (NULL != (msg = tor_socksauth_keyval_check(TRUNNEL_DYNARRAY_GET(&obj->pairs, idx))))
- return msg;
- }
- }
- if (TRUNNEL_DYNARRAY_LEN(&obj->pairs) != obj->npairs)
- return "Length mismatch for pairs";
- return NULL;
-}
-
-ssize_t
-tor_extended_socks_auth_request_encoded_len(const tor_extended_socks_auth_request_t *obj)
-{
- ssize_t result = 0;
-
- if (NULL != tor_extended_socks_auth_request_check(obj))
- return -1;
-
-
- /* Length of u8 version IN [1] */
- result += 1;
-
- /* Length of u16 npairs */
- result += 2;
-
- /* Length of struct tor_socksauth_keyval pairs[npairs] */
- {
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- result += tor_socksauth_keyval_encoded_len(TRUNNEL_DYNARRAY_GET(&obj->pairs, idx));
- }
- }
- return result;
-}
-int
-tor_extended_socks_auth_request_clear_errors(tor_extended_socks_auth_request_t *obj)
-{
- int r = obj->trunnel_error_code_;
- obj->trunnel_error_code_ = 0;
- return r;
-}
-ssize_t
-tor_extended_socks_auth_request_encode(uint8_t *output, const size_t avail, const tor_extended_socks_auth_request_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 = tor_extended_socks_auth_request_encoded_len(obj);
-#endif
-
- if (NULL != (msg = tor_extended_socks_auth_request_check(obj)))
- goto check_failed;
-
-#ifdef TRUNNEL_CHECK_ENCODED_LEN
- trunnel_assert(encoded_len >= 0);
-#endif
-
- /* Encode u8 version IN [1] */
- trunnel_assert(written <= avail);
- if (avail - written < 1)
- goto truncated;
- trunnel_set_uint8(ptr, (obj->version));
- written += 1; ptr += 1;
-
- /* Encode u16 npairs */
- trunnel_assert(written <= avail);
- if (avail - written < 2)
- goto truncated;
- trunnel_set_uint16(ptr, trunnel_htons(obj->npairs));
- written += 2; ptr += 2;
-
- /* Encode struct tor_socksauth_keyval pairs[npairs] */
- {
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- trunnel_assert(written <= avail);
- result = tor_socksauth_keyval_encode(ptr, avail - written, TRUNNEL_DYNARRAY_GET(&obj->pairs, idx));
- if (result < 0)
- goto fail; /* XXXXXXX !*/
- written += result; ptr += result;
- }
- }
-
-
- 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;
-}
-
-/** As tor_extended_socks_auth_request_parse(), but do not allocate
- * the output object.
- */
-static ssize_t
-tor_extended_socks_auth_request_parse_into(tor_extended_socks_auth_request_t *obj, const uint8_t *input, const size_t len_in)
-{
- const uint8_t *ptr = input;
- size_t remaining = len_in;
- ssize_t result = 0;
- (void)result;
-
- /* Parse u8 version IN [1] */
- CHECK_REMAINING(1, truncated);
- obj->version = (trunnel_get_uint8(ptr));
- remaining -= 1; ptr += 1;
- if (! (obj->version == 1))
- goto fail;
-
- /* Parse u16 npairs */
- CHECK_REMAINING(2, truncated);
- obj->npairs = trunnel_ntohs(trunnel_get_uint16(ptr));
- remaining -= 2; ptr += 2;
-
- /* Parse struct tor_socksauth_keyval pairs[npairs] */
- TRUNNEL_DYNARRAY_EXPAND(tor_socksauth_keyval_t *, &obj->pairs, obj->npairs, {});
- {
- tor_socksauth_keyval_t * elt;
- unsigned idx;
- for (idx = 0; idx < obj->npairs; ++idx) {
- result = tor_socksauth_keyval_parse(&elt, ptr, remaining);
- if (result < 0)
- goto relay_fail;
- trunnel_assert((size_t)result <= remaining);
- remaining -= result; ptr += result;
- TRUNNEL_DYNARRAY_ADD(tor_socksauth_keyval_t *, &obj->pairs, elt, {tor_socksauth_keyval_free(elt);});
- }
- }
- trunnel_assert(ptr + remaining == input + len_in);
- return len_in - remaining;
-
- truncated:
- return -2;
- relay_fail:
- trunnel_assert(result < 0);
- return result;
- trunnel_alloc_failed:
- return -1;
- fail:
- result = -1;
- return result;
-}
-
-ssize_t
-tor_extended_socks_auth_request_parse(tor_extended_socks_auth_request_t **output, const uint8_t *input, const size_t len_in)
-{
- ssize_t result;
- *output = tor_extended_socks_auth_request_new();
- if (NULL == *output)
- return -1;
- result = tor_extended_socks_auth_request_parse_into(*output, input, len_in);
- if (result < 0) {
- tor_extended_socks_auth_request_free(*output);
- *output = NULL;
- }
- return result;
-}
-tor_extended_socks_auth_response_t *
-tor_extended_socks_auth_response_new(void)
-{
- tor_extended_socks_auth_response_t *val = trunnel_calloc(1, sizeof(tor_extended_socks_auth_response_t));
- if (NULL == val)
- return NULL;
- val->version = 1;
- return val;
-}
-
-/** Release all storage held inside 'obj', but do not free 'obj'.
- */
-static void
-tor_extended_socks_auth_response_clear(tor_extended_socks_auth_response_t *obj)
-{
- (void) obj;
- {
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- tor_socksauth_keyval_free(TRUNNEL_DYNARRAY_GET(&obj->pairs, idx));
- }
- }
- TRUNNEL_DYNARRAY_WIPE(&obj->pairs);
- TRUNNEL_DYNARRAY_CLEAR(&obj->pairs);
-}
-
-void
-tor_extended_socks_auth_response_free(tor_extended_socks_auth_response_t *obj)
-{
- if (obj == NULL)
- return;
- tor_extended_socks_auth_response_clear(obj);
- trunnel_memwipe(obj, sizeof(tor_extended_socks_auth_response_t));
- trunnel_free_(obj);
-}
-
-uint8_t
-tor_extended_socks_auth_response_get_version(const tor_extended_socks_auth_response_t *inp)
-{
- return inp->version;
-}
-int
-tor_extended_socks_auth_response_set_version(tor_extended_socks_auth_response_t *inp, uint8_t val)
-{
- if (! ((val == 1))) {
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
- }
- inp->version = val;
- return 0;
-}
-uint8_t
-tor_extended_socks_auth_response_get_status(const tor_extended_socks_auth_response_t *inp)
-{
- return inp->status;
-}
-int
-tor_extended_socks_auth_response_set_status(tor_extended_socks_auth_response_t *inp, uint8_t val)
-{
- inp->status = val;
- return 0;
-}
-uint16_t
-tor_extended_socks_auth_response_get_npairs(const tor_extended_socks_auth_response_t *inp)
-{
- return inp->npairs;
-}
-int
-tor_extended_socks_auth_response_set_npairs(tor_extended_socks_auth_response_t *inp, uint16_t val)
-{
- inp->npairs = val;
- return 0;
-}
-size_t
-tor_extended_socks_auth_response_getlen_pairs(const tor_extended_socks_auth_response_t *inp)
-{
- return TRUNNEL_DYNARRAY_LEN(&inp->pairs);
-}
-
-struct tor_socksauth_keyval_st *
-tor_extended_socks_auth_response_get_pairs(tor_extended_socks_auth_response_t *inp, size_t idx)
-{
- return TRUNNEL_DYNARRAY_GET(&inp->pairs, idx);
-}
-
- const struct tor_socksauth_keyval_st *
-tor_extended_socks_auth_response_getconst_pairs(const tor_extended_socks_auth_response_t *inp, size_t idx)
-{
- return tor_extended_socks_auth_response_get_pairs((tor_extended_socks_auth_response_t*)inp, idx);
-}
-int
-tor_extended_socks_auth_response_set_pairs(tor_extended_socks_auth_response_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt)
-{
- tor_socksauth_keyval_t *oldval = TRUNNEL_DYNARRAY_GET(&inp->pairs, idx);
- if (oldval && oldval != elt)
- tor_socksauth_keyval_free(oldval);
- return tor_extended_socks_auth_response_set0_pairs(inp, idx, elt);
-}
-int
-tor_extended_socks_auth_response_set0_pairs(tor_extended_socks_auth_response_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt)
-{
- TRUNNEL_DYNARRAY_SET(&inp->pairs, idx, elt);
- return 0;
-}
-int
-tor_extended_socks_auth_response_add_pairs(tor_extended_socks_auth_response_t *inp, struct tor_socksauth_keyval_st * elt)
-{
-#if SIZE_MAX >= UINT16_MAX
- if (inp->pairs.n_ == UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- TRUNNEL_DYNARRAY_ADD(struct tor_socksauth_keyval_st *, &inp->pairs, elt, {});
- return 0;
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-
-struct tor_socksauth_keyval_st * *
-tor_extended_socks_auth_response_getarray_pairs(tor_extended_socks_auth_response_t *inp)
-{
- return inp->pairs.elts_;
-}
-const struct tor_socksauth_keyval_st * const *
-tor_extended_socks_auth_response_getconstarray_pairs(const tor_extended_socks_auth_response_t *inp)
-{
- return (const struct tor_socksauth_keyval_st * const *)tor_extended_socks_auth_response_getarray_pairs((tor_extended_socks_auth_response_t*)inp);
-}
-int
-tor_extended_socks_auth_response_setlen_pairs(tor_extended_socks_auth_response_t *inp, size_t newlen)
-{
- struct tor_socksauth_keyval_st * *newptr;
-#if UINT16_MAX < SIZE_MAX
- if (newlen > UINT16_MAX)
- goto trunnel_alloc_failed;
-#endif
- newptr = trunnel_dynarray_setlen(&inp->pairs.allocated_,
- &inp->pairs.n_, inp->pairs.elts_, newlen,
- sizeof(inp->pairs.elts_[0]), (trunnel_free_fn_t) tor_socksauth_keyval_free,
- &inp->trunnel_error_code_);
- if (newlen != 0 && newptr == NULL)
- goto trunnel_alloc_failed;
- inp->pairs.elts_ = newptr;
- return 0;
- trunnel_alloc_failed:
- TRUNNEL_SET_ERROR_CODE(inp);
- return -1;
-}
-const char *
-tor_extended_socks_auth_response_check(const tor_extended_socks_auth_response_t *obj)
-{
- if (obj == NULL)
- return "Object was NULL";
- if (obj->trunnel_error_code_)
- return "A set function failed on this object";
- if (! (obj->version == 1))
- return "Integer out of bounds";
- {
- const char *msg;
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- if (NULL != (msg = tor_socksauth_keyval_check(TRUNNEL_DYNARRAY_GET(&obj->pairs, idx))))
- return msg;
- }
- }
- if (TRUNNEL_DYNARRAY_LEN(&obj->pairs) != obj->npairs)
- return "Length mismatch for pairs";
- return NULL;
-}
-
-ssize_t
-tor_extended_socks_auth_response_encoded_len(const tor_extended_socks_auth_response_t *obj)
-{
- ssize_t result = 0;
-
- if (NULL != tor_extended_socks_auth_response_check(obj))
- return -1;
-
-
- /* Length of u8 version IN [1] */
- result += 1;
-
- /* Length of u8 status */
- result += 1;
-
- /* Length of u16 npairs */
- result += 2;
-
- /* Length of struct tor_socksauth_keyval pairs[npairs] */
- {
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- result += tor_socksauth_keyval_encoded_len(TRUNNEL_DYNARRAY_GET(&obj->pairs, idx));
- }
- }
- return result;
-}
-int
-tor_extended_socks_auth_response_clear_errors(tor_extended_socks_auth_response_t *obj)
-{
- int r = obj->trunnel_error_code_;
- obj->trunnel_error_code_ = 0;
- return r;
-}
-ssize_t
-tor_extended_socks_auth_response_encode(uint8_t *output, const size_t avail, const tor_extended_socks_auth_response_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 = tor_extended_socks_auth_response_encoded_len(obj);
-#endif
-
- if (NULL != (msg = tor_extended_socks_auth_response_check(obj)))
- goto check_failed;
-
-#ifdef TRUNNEL_CHECK_ENCODED_LEN
- trunnel_assert(encoded_len >= 0);
-#endif
-
- /* Encode u8 version IN [1] */
- trunnel_assert(written <= avail);
- if (avail - written < 1)
- goto truncated;
- trunnel_set_uint8(ptr, (obj->version));
- written += 1; ptr += 1;
-
- /* Encode u8 status */
- trunnel_assert(written <= avail);
- if (avail - written < 1)
- goto truncated;
- trunnel_set_uint8(ptr, (obj->status));
- written += 1; ptr += 1;
-
- /* Encode u16 npairs */
- trunnel_assert(written <= avail);
- if (avail - written < 2)
- goto truncated;
- trunnel_set_uint16(ptr, trunnel_htons(obj->npairs));
- written += 2; ptr += 2;
-
- /* Encode struct tor_socksauth_keyval pairs[npairs] */
- {
-
- unsigned idx;
- for (idx = 0; idx < TRUNNEL_DYNARRAY_LEN(&obj->pairs); ++idx) {
- trunnel_assert(written <= avail);
- result = tor_socksauth_keyval_encode(ptr, avail - written, TRUNNEL_DYNARRAY_GET(&obj->pairs, idx));
- if (result < 0)
- goto fail; /* XXXXXXX !*/
- written += result; ptr += result;
- }
- }
-
-
- 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;
-}
-
-/** As tor_extended_socks_auth_response_parse(), but do not allocate
- * the output object.
- */
-static ssize_t
-tor_extended_socks_auth_response_parse_into(tor_extended_socks_auth_response_t *obj, const uint8_t *input, const size_t len_in)
-{
- const uint8_t *ptr = input;
- size_t remaining = len_in;
- ssize_t result = 0;
- (void)result;
-
- /* Parse u8 version IN [1] */
- CHECK_REMAINING(1, truncated);
- obj->version = (trunnel_get_uint8(ptr));
- remaining -= 1; ptr += 1;
- if (! (obj->version == 1))
- goto fail;
-
- /* Parse u8 status */
- CHECK_REMAINING(1, truncated);
- obj->status = (trunnel_get_uint8(ptr));
- remaining -= 1; ptr += 1;
-
- /* Parse u16 npairs */
- CHECK_REMAINING(2, truncated);
- obj->npairs = trunnel_ntohs(trunnel_get_uint16(ptr));
- remaining -= 2; ptr += 2;
-
- /* Parse struct tor_socksauth_keyval pairs[npairs] */
- TRUNNEL_DYNARRAY_EXPAND(tor_socksauth_keyval_t *, &obj->pairs, obj->npairs, {});
- {
- tor_socksauth_keyval_t * elt;
- unsigned idx;
- for (idx = 0; idx < obj->npairs; ++idx) {
- result = tor_socksauth_keyval_parse(&elt, ptr, remaining);
- if (result < 0)
- goto relay_fail;
- trunnel_assert((size_t)result <= remaining);
- remaining -= result; ptr += result;
- TRUNNEL_DYNARRAY_ADD(tor_socksauth_keyval_t *, &obj->pairs, elt, {tor_socksauth_keyval_free(elt);});
- }
- }
- trunnel_assert(ptr + remaining == input + len_in);
- return len_in - remaining;
-
- truncated:
- return -2;
- relay_fail:
- trunnel_assert(result < 0);
- return result;
- trunnel_alloc_failed:
- return -1;
- fail:
- result = -1;
- return result;
-}
-
-ssize_t
-tor_extended_socks_auth_response_parse(tor_extended_socks_auth_response_t **output, const uint8_t *input, const size_t len_in)
-{
- ssize_t result;
- *output = tor_extended_socks_auth_response_new();
- if (NULL == *output)
- return -1;
- result = tor_extended_socks_auth_response_parse_into(*output, input, len_in);
- if (result < 0) {
- tor_extended_socks_auth_response_free(*output);
- *output = NULL;
- }
- return result;
-}
diff --git a/src/trunnel/socks5.h b/src/trunnel/socks5.h
index d8f13c2abb..d3bea152e7 100644
--- a/src/trunnel/socks5.h
+++ b/src/trunnel/socks5.h
@@ -82,16 +82,6 @@ struct socks5_server_userpass_auth_st {
};
#endif
typedef struct socks5_server_userpass_auth_st socks5_server_userpass_auth_t;
-#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_SOCKSAUTH_KEYVAL)
-struct tor_socksauth_keyval_st {
- uint16_t keylen;
- trunnel_string_t key;
- uint16_t vallen;
- trunnel_string_t val;
- uint8_t trunnel_error_code_;
-};
-#endif
-typedef struct tor_socksauth_keyval_st tor_socksauth_keyval_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_REQUEST)
struct socks5_client_request_st {
uint8_t version;
@@ -120,25 +110,6 @@ struct socks5_server_reply_st {
};
#endif
typedef struct socks5_server_reply_st socks5_server_reply_t;
-#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_EXTENDED_SOCKS_AUTH_REQUEST)
-struct tor_extended_socks_auth_request_st {
- uint8_t version;
- uint16_t npairs;
- TRUNNEL_DYNARRAY_HEAD(, struct tor_socksauth_keyval_st *) pairs;
- uint8_t trunnel_error_code_;
-};
-#endif
-typedef struct tor_extended_socks_auth_request_st tor_extended_socks_auth_request_t;
-#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_EXTENDED_SOCKS_AUTH_RESPONSE)
-struct tor_extended_socks_auth_response_st {
- uint8_t version;
- uint8_t status;
- uint16_t npairs;
- TRUNNEL_DYNARRAY_HEAD(, struct tor_socksauth_keyval_st *) pairs;
- uint8_t trunnel_error_code_;
-};
-#endif
-typedef struct tor_extended_socks_auth_response_st tor_extended_socks_auth_response_t;
/** Return a newly allocated domainname with all elements set to zero.
*/
domainname_t *domainname_new(void);
@@ -753,154 +724,6 @@ uint8_t socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth
* success; return -1 and set the error code on 'inp' on failure.
*/
int socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val);
-/** Return a newly allocated tor_socksauth_keyval with all elements
- * set to zero.
- */
-tor_socksauth_keyval_t *tor_socksauth_keyval_new(void);
-/** Release all storage held by the tor_socksauth_keyval in 'victim'.
- * (Do nothing if 'victim' is NULL.)
- */
-void tor_socksauth_keyval_free(tor_socksauth_keyval_t *victim);
-/** Try to parse a tor_socksauth_keyval from the buffer in 'input',
- * using up to 'len_in' bytes from the input buffer. On success,
- * return the number of bytes consumed and set *output to the newly
- * allocated tor_socksauth_keyval_t. On failure, return -2 if the
- * input appears truncated, and -1 if the input is otherwise invalid.
- */
-ssize_t tor_socksauth_keyval_parse(tor_socksauth_keyval_t **output, const uint8_t *input, const size_t len_in);
-/** Return the number of bytes we expect to need to encode the
- * tor_socksauth_keyval in 'obj'. On failure, return a negative value.
- * Note that this value may be an overestimate, and can even be an
- * underestimate for certain unencodeable objects.
- */
-ssize_t tor_socksauth_keyval_encoded_len(const tor_socksauth_keyval_t *obj);
-/** Try to encode the tor_socksauth_keyval from 'input' into the
- * buffer at 'output', using up to 'avail' bytes of the output buffer.
- * On success, return the number of bytes used. On failure, return -2
- * if the buffer was not long enough, and -1 if the input was invalid.
- */
-ssize_t tor_socksauth_keyval_encode(uint8_t *output, size_t avail, const tor_socksauth_keyval_t *input);
-/** Check whether the internal state of the tor_socksauth_keyval in
- * 'obj' is consistent. Return NULL if it is, and a short message if
- * it is not.
- */
-const char *tor_socksauth_keyval_check(const tor_socksauth_keyval_t *obj);
-/** Clear any errors that were set on the object 'obj' by its setter
- * functions. Return true iff errors were cleared.
- */
-int tor_socksauth_keyval_clear_errors(tor_socksauth_keyval_t *obj);
-/** Return the value of the keylen field of the tor_socksauth_keyval_t
- * in 'inp'
- */
-uint16_t tor_socksauth_keyval_get_keylen(const tor_socksauth_keyval_t *inp);
-/** Set the value of the keylen field of the tor_socksauth_keyval_t in
- * 'inp' to 'val'. Return 0 on success; return -1 and set the error
- * code on 'inp' on failure.
- */
-int tor_socksauth_keyval_set_keylen(tor_socksauth_keyval_t *inp, uint16_t val);
-/** Return the length of the dynamic array holding the key field of
- * the tor_socksauth_keyval_t in 'inp'.
- */
-size_t tor_socksauth_keyval_getlen_key(const tor_socksauth_keyval_t *inp);
-/** Return the element at position 'idx' of the dynamic array field
- * key of the tor_socksauth_keyval_t in 'inp'.
- */
-char tor_socksauth_keyval_get_key(tor_socksauth_keyval_t *inp, size_t idx);
-/** As tor_socksauth_keyval_get_key, but take and return a const
- * pointer
- */
-char tor_socksauth_keyval_getconst_key(const tor_socksauth_keyval_t *inp, size_t idx);
-/** Change the element at position 'idx' of the dynamic array field
- * key of the tor_socksauth_keyval_t in 'inp', so that it will hold
- * the value 'elt'.
- */
-int tor_socksauth_keyval_set_key(tor_socksauth_keyval_t *inp, size_t idx, char elt);
-/** Append a new element 'elt' to the dynamic array field key of the
- * tor_socksauth_keyval_t in 'inp'.
- */
-int tor_socksauth_keyval_add_key(tor_socksauth_keyval_t *inp, char elt);
-/** Return a pointer to the variable-length array field key of 'inp'.
- */
-char * tor_socksauth_keyval_getarray_key(tor_socksauth_keyval_t *inp);
-/** As tor_socksauth_keyval_get_key, but take and return a const
- * pointer
- */
-const char * tor_socksauth_keyval_getconstarray_key(const tor_socksauth_keyval_t *inp);
-/** Change the length of the variable-length array field key of 'inp'
- * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
- * -1 and set the error code on 'inp' on failure.
- */
-int tor_socksauth_keyval_setlen_key(tor_socksauth_keyval_t *inp, size_t newlen);
-/** Return the value of the key field of a tor_socksauth_keyval_t as a
- * NUL-terminated string.
- */
-const char * tor_socksauth_keyval_getstr_key(tor_socksauth_keyval_t *inp);
-/** Set the value of the key field of a tor_socksauth_keyval_t to a
- * given string of length 'len'. Return 0 on success; return -1 and
- * set the error code on 'inp' on failure.
- */
-int tor_socksauth_keyval_setstr0_key(tor_socksauth_keyval_t *inp, const char *val, size_t len);
-/** Set the value of the key field of a tor_socksauth_keyval_t to a
- * given NUL-terminated string. Return 0 on success; return -1 and set
- * the error code on 'inp' on failure.
- */
-int tor_socksauth_keyval_setstr_key(tor_socksauth_keyval_t *inp, const char *val);
-/** Return the value of the vallen field of the tor_socksauth_keyval_t
- * in 'inp'
- */
-uint16_t tor_socksauth_keyval_get_vallen(const tor_socksauth_keyval_t *inp);
-/** Set the value of the vallen field of the tor_socksauth_keyval_t in
- * 'inp' to 'val'. Return 0 on success; return -1 and set the error
- * code on 'inp' on failure.
- */
-int tor_socksauth_keyval_set_vallen(tor_socksauth_keyval_t *inp, uint16_t val);
-/** Return the length of the dynamic array holding the val field of
- * the tor_socksauth_keyval_t in 'inp'.
- */
-size_t tor_socksauth_keyval_getlen_val(const tor_socksauth_keyval_t *inp);
-/** Return the element at position 'idx' of the dynamic array field
- * val of the tor_socksauth_keyval_t in 'inp'.
- */
-char tor_socksauth_keyval_get_val(tor_socksauth_keyval_t *inp, size_t idx);
-/** As tor_socksauth_keyval_get_val, but take and return a const
- * pointer
- */
-char tor_socksauth_keyval_getconst_val(const tor_socksauth_keyval_t *inp, size_t idx);
-/** Change the element at position 'idx' of the dynamic array field
- * val of the tor_socksauth_keyval_t in 'inp', so that it will hold
- * the value 'elt'.
- */
-int tor_socksauth_keyval_set_val(tor_socksauth_keyval_t *inp, size_t idx, char elt);
-/** Append a new element 'elt' to the dynamic array field val of the
- * tor_socksauth_keyval_t in 'inp'.
- */
-int tor_socksauth_keyval_add_val(tor_socksauth_keyval_t *inp, char elt);
-/** Return a pointer to the variable-length array field val of 'inp'.
- */
-char * tor_socksauth_keyval_getarray_val(tor_socksauth_keyval_t *inp);
-/** As tor_socksauth_keyval_get_val, but take and return a const
- * pointer
- */
-const char * tor_socksauth_keyval_getconstarray_val(const tor_socksauth_keyval_t *inp);
-/** Change the length of the variable-length array field val of 'inp'
- * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
- * -1 and set the error code on 'inp' on failure.
- */
-int tor_socksauth_keyval_setlen_val(tor_socksauth_keyval_t *inp, size_t newlen);
-/** Return the value of the val field of a tor_socksauth_keyval_t as a
- * NUL-terminated string.
- */
-const char * tor_socksauth_keyval_getstr_val(tor_socksauth_keyval_t *inp);
-/** Set the value of the val field of a tor_socksauth_keyval_t to a
- * given string of length 'len'. Return 0 on success; return -1 and
- * set the error code on 'inp' on failure.
- */
-int tor_socksauth_keyval_setstr0_val(tor_socksauth_keyval_t *inp, const char *val, size_t len);
-/** Set the value of the val field of a tor_socksauth_keyval_t to a
- * given NUL-terminated string. Return 0 on success; return -1 and set
- * the error code on 'inp' on failure.
- */
-int tor_socksauth_keyval_setstr_val(tor_socksauth_keyval_t *inp, const char *val);
/** Return a newly allocated socks5_client_request with all elements
* set to zero.
*/
@@ -1167,205 +990,6 @@ uint16_t socks5_server_reply_get_bind_port(const socks5_server_reply_t *inp);
* code on 'inp' on failure.
*/
int socks5_server_reply_set_bind_port(socks5_server_reply_t *inp, uint16_t val);
-/** Return a newly allocated tor_extended_socks_auth_request with all
- * elements set to zero.
- */
-tor_extended_socks_auth_request_t *tor_extended_socks_auth_request_new(void);
-/** Release all storage held by the tor_extended_socks_auth_request in
- * 'victim'. (Do nothing if 'victim' is NULL.)
- */
-void tor_extended_socks_auth_request_free(tor_extended_socks_auth_request_t *victim);
-/** Try to parse a tor_extended_socks_auth_request from the buffer in
- * 'input', using up to 'len_in' bytes from the input buffer. On
- * success, return the number of bytes consumed and set *output to the
- * newly allocated tor_extended_socks_auth_request_t. On failure,
- * return -2 if the input appears truncated, and -1 if the input is
- * otherwise invalid.
- */
-ssize_t tor_extended_socks_auth_request_parse(tor_extended_socks_auth_request_t **output, const uint8_t *input, const size_t len_in);
-/** Return the number of bytes we expect to need to encode the
- * tor_extended_socks_auth_request in 'obj'. On failure, return a
- * negative value. Note that this value may be an overestimate, and
- * can even be an underestimate for certain unencodeable objects.
- */
-ssize_t tor_extended_socks_auth_request_encoded_len(const tor_extended_socks_auth_request_t *obj);
-/** Try to encode the tor_extended_socks_auth_request from 'input'
- * into the buffer at 'output', using up to 'avail' bytes of the
- * output buffer. On success, return the number of bytes used. On
- * failure, return -2 if the buffer was not long enough, and -1 if the
- * input was invalid.
- */
-ssize_t tor_extended_socks_auth_request_encode(uint8_t *output, size_t avail, const tor_extended_socks_auth_request_t *input);
-/** Check whether the internal state of the
- * tor_extended_socks_auth_request in 'obj' is consistent. Return NULL
- * if it is, and a short message if it is not.
- */
-const char *tor_extended_socks_auth_request_check(const tor_extended_socks_auth_request_t *obj);
-/** Clear any errors that were set on the object 'obj' by its setter
- * functions. Return true iff errors were cleared.
- */
-int tor_extended_socks_auth_request_clear_errors(tor_extended_socks_auth_request_t *obj);
-/** Return the value of the version field of the
- * tor_extended_socks_auth_request_t in 'inp'
- */
-uint8_t tor_extended_socks_auth_request_get_version(const tor_extended_socks_auth_request_t *inp);
-/** Set the value of the version field of the
- * tor_extended_socks_auth_request_t in 'inp' to 'val'. Return 0 on
- * success; return -1 and set the error code on 'inp' on failure.
- */
-int tor_extended_socks_auth_request_set_version(tor_extended_socks_auth_request_t *inp, uint8_t val);
-/** Return the value of the npairs field of the
- * tor_extended_socks_auth_request_t in 'inp'
- */
-uint16_t tor_extended_socks_auth_request_get_npairs(const tor_extended_socks_auth_request_t *inp);
-/** Set the value of the npairs field of the
- * tor_extended_socks_auth_request_t in 'inp' to 'val'. Return 0 on
- * success; return -1 and set the error code on 'inp' on failure.
- */
-int tor_extended_socks_auth_request_set_npairs(tor_extended_socks_auth_request_t *inp, uint16_t val);
-/** Return the length of the dynamic array holding the pairs field of
- * the tor_extended_socks_auth_request_t in 'inp'.
- */
-size_t tor_extended_socks_auth_request_getlen_pairs(const tor_extended_socks_auth_request_t *inp);
-/** Return the element at position 'idx' of the dynamic array field
- * pairs of the tor_extended_socks_auth_request_t in 'inp'.
- */
-struct tor_socksauth_keyval_st * tor_extended_socks_auth_request_get_pairs(tor_extended_socks_auth_request_t *inp, size_t idx);
-/** As tor_extended_socks_auth_request_get_pairs, but take and return
- * a const pointer
- */
- const struct tor_socksauth_keyval_st * tor_extended_socks_auth_request_getconst_pairs(const tor_extended_socks_auth_request_t *inp, size_t idx);
-/** Change the element at position 'idx' of the dynamic array field
- * pairs of the tor_extended_socks_auth_request_t in 'inp', so that it
- * will hold the value 'elt'. Free the previous value, if any.
- */
-int tor_extended_socks_auth_request_set_pairs(tor_extended_socks_auth_request_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
-/** As tor_extended_socks_auth_request_set_pairs, but does not free
- * the previous value.
- */
-int tor_extended_socks_auth_request_set0_pairs(tor_extended_socks_auth_request_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
-/** Append a new element 'elt' to the dynamic array field pairs of the
- * tor_extended_socks_auth_request_t in 'inp'.
- */
-int tor_extended_socks_auth_request_add_pairs(tor_extended_socks_auth_request_t *inp, struct tor_socksauth_keyval_st * elt);
-/** Return a pointer to the variable-length array field pairs of
- * 'inp'.
- */
-struct tor_socksauth_keyval_st * * tor_extended_socks_auth_request_getarray_pairs(tor_extended_socks_auth_request_t *inp);
-/** As tor_extended_socks_auth_request_get_pairs, but take and return
- * a const pointer
- */
-const struct tor_socksauth_keyval_st * const * tor_extended_socks_auth_request_getconstarray_pairs(const tor_extended_socks_auth_request_t *inp);
-/** Change the length of the variable-length array field pairs of
- * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
- * elements. Return 0 on success; return -1 and set the error code on
- * 'inp' on failure.
- */
-int tor_extended_socks_auth_request_setlen_pairs(tor_extended_socks_auth_request_t *inp, size_t newlen);
-/** Return a newly allocated tor_extended_socks_auth_response with all
- * elements set to zero.
- */
-tor_extended_socks_auth_response_t *tor_extended_socks_auth_response_new(void);
-/** Release all storage held by the tor_extended_socks_auth_response
- * in 'victim'. (Do nothing if 'victim' is NULL.)
- */
-void tor_extended_socks_auth_response_free(tor_extended_socks_auth_response_t *victim);
-/** Try to parse a tor_extended_socks_auth_response from the buffer in
- * 'input', using up to 'len_in' bytes from the input buffer. On
- * success, return the number of bytes consumed and set *output to the
- * newly allocated tor_extended_socks_auth_response_t. On failure,
- * return -2 if the input appears truncated, and -1 if the input is
- * otherwise invalid.
- */
-ssize_t tor_extended_socks_auth_response_parse(tor_extended_socks_auth_response_t **output, const uint8_t *input, const size_t len_in);
-/** Return the number of bytes we expect to need to encode the
- * tor_extended_socks_auth_response in 'obj'. On failure, return a
- * negative value. Note that this value may be an overestimate, and
- * can even be an underestimate for certain unencodeable objects.
- */
-ssize_t tor_extended_socks_auth_response_encoded_len(const tor_extended_socks_auth_response_t *obj);
-/** Try to encode the tor_extended_socks_auth_response from 'input'
- * into the buffer at 'output', using up to 'avail' bytes of the
- * output buffer. On success, return the number of bytes used. On
- * failure, return -2 if the buffer was not long enough, and -1 if the
- * input was invalid.
- */
-ssize_t tor_extended_socks_auth_response_encode(uint8_t *output, size_t avail, const tor_extended_socks_auth_response_t *input);
-/** Check whether the internal state of the
- * tor_extended_socks_auth_response in 'obj' is consistent. Return
- * NULL if it is, and a short message if it is not.
- */
-const char *tor_extended_socks_auth_response_check(const tor_extended_socks_auth_response_t *obj);
-/** Clear any errors that were set on the object 'obj' by its setter
- * functions. Return true iff errors were cleared.
- */
-int tor_extended_socks_auth_response_clear_errors(tor_extended_socks_auth_response_t *obj);
-/** Return the value of the version field of the
- * tor_extended_socks_auth_response_t in 'inp'
- */
-uint8_t tor_extended_socks_auth_response_get_version(const tor_extended_socks_auth_response_t *inp);
-/** Set the value of the version field of the
- * tor_extended_socks_auth_response_t in 'inp' to 'val'. Return 0 on
- * success; return -1 and set the error code on 'inp' on failure.
- */
-int tor_extended_socks_auth_response_set_version(tor_extended_socks_auth_response_t *inp, uint8_t val);
-/** Return the value of the status field of the
- * tor_extended_socks_auth_response_t in 'inp'
- */
-uint8_t tor_extended_socks_auth_response_get_status(const tor_extended_socks_auth_response_t *inp);
-/** Set the value of the status field of the
- * tor_extended_socks_auth_response_t in 'inp' to 'val'. Return 0 on
- * success; return -1 and set the error code on 'inp' on failure.
- */
-int tor_extended_socks_auth_response_set_status(tor_extended_socks_auth_response_t *inp, uint8_t val);
-/** Return the value of the npairs field of the
- * tor_extended_socks_auth_response_t in 'inp'
- */
-uint16_t tor_extended_socks_auth_response_get_npairs(const tor_extended_socks_auth_response_t *inp);
-/** Set the value of the npairs field of the
- * tor_extended_socks_auth_response_t in 'inp' to 'val'. Return 0 on
- * success; return -1 and set the error code on 'inp' on failure.
- */
-int tor_extended_socks_auth_response_set_npairs(tor_extended_socks_auth_response_t *inp, uint16_t val);
-/** Return the length of the dynamic array holding the pairs field of
- * the tor_extended_socks_auth_response_t in 'inp'.
- */
-size_t tor_extended_socks_auth_response_getlen_pairs(const tor_extended_socks_auth_response_t *inp);
-/** Return the element at position 'idx' of the dynamic array field
- * pairs of the tor_extended_socks_auth_response_t in 'inp'.
- */
-struct tor_socksauth_keyval_st * tor_extended_socks_auth_response_get_pairs(tor_extended_socks_auth_response_t *inp, size_t idx);
-/** As tor_extended_socks_auth_response_get_pairs, but take and return
- * a const pointer
- */
- const struct tor_socksauth_keyval_st * tor_extended_socks_auth_response_getconst_pairs(const tor_extended_socks_auth_response_t *inp, size_t idx);
-/** Change the element at position 'idx' of the dynamic array field
- * pairs of the tor_extended_socks_auth_response_t in 'inp', so that
- * it will hold the value 'elt'. Free the previous value, if any.
- */
-int tor_extended_socks_auth_response_set_pairs(tor_extended_socks_auth_response_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
-/** As tor_extended_socks_auth_response_set_pairs, but does not free
- * the previous value.
- */
-int tor_extended_socks_auth_response_set0_pairs(tor_extended_socks_auth_response_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
-/** Append a new element 'elt' to the dynamic array field pairs of the
- * tor_extended_socks_auth_response_t in 'inp'.
- */
-int tor_extended_socks_auth_response_add_pairs(tor_extended_socks_auth_response_t *inp, struct tor_socksauth_keyval_st * elt);
-/** Return a pointer to the variable-length array field pairs of
- * 'inp'.
- */
-struct tor_socksauth_keyval_st * * tor_extended_socks_auth_response_getarray_pairs(tor_extended_socks_auth_response_t *inp);
-/** As tor_extended_socks_auth_response_get_pairs, but take and return
- * a const pointer
- */
-const struct tor_socksauth_keyval_st * const * tor_extended_socks_auth_response_getconstarray_pairs(const tor_extended_socks_auth_response_t *inp);
-/** Change the length of the variable-length array field pairs of
- * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
- * elements. Return 0 on success; return -1 and set the error code on
- * 'inp' on failure.
- */
-int tor_extended_socks_auth_response_setlen_pairs(tor_extended_socks_auth_response_t *inp, size_t newlen);
#endif
diff --git a/src/trunnel/socks5.trunnel b/src/trunnel/socks5.trunnel
index d70ad639e2..b86ec03b9d 100644
--- a/src/trunnel/socks5.trunnel
+++ b/src/trunnel/socks5.trunnel
@@ -92,25 +92,3 @@ struct socks4_server_reply {
u32 addr;
}
-// And here's the extended stuff from proposal 229
-
-struct tor_socksauth_keyval {
- u16 keylen;
- char key[keylen];
- u16 vallen;
- char val[vallen];
-}
-
-struct tor_extended_socks_auth_request {
- u8 version IN [1];
- u16 npairs;
- struct tor_socksauth_keyval pairs[npairs];
-}
-
-struct tor_extended_socks_auth_response {
- u8 version IN [1];
- u8 status;
- u16 npairs;
- struct tor_socksauth_keyval pairs[npairs];
-}
-