tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

pwbox.h (8608B)


      1 /* pwbox.h -- generated by Trunnel v1.5.3.
      2 * https://gitweb.torproject.org/trunnel.git
      3 * You probably shouldn't edit this file.
      4 */
      5 #ifndef TRUNNEL_PWBOX_H
      6 #define TRUNNEL_PWBOX_H
      7 
      8 #include <stdint.h>
      9 #include "trunnel.h"
     10 
     11 #define PWBOX0_CONST0 1414484546
     12 #define PWBOX0_CONST1 1331179568
     13 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_PWBOX_ENCODED)
     14 struct pwbox_encoded_st {
     15  uint32_t fixedbytes0;
     16  uint32_t fixedbytes1;
     17  uint8_t header_len;
     18  TRUNNEL_DYNARRAY_HEAD(, uint8_t) skey_header;
     19  uint8_t iv[16];
     20  TRUNNEL_DYNARRAY_HEAD(, uint8_t) data;
     21  uint8_t hmac[32];
     22  uint8_t trunnel_error_code_;
     23 };
     24 #endif
     25 typedef struct pwbox_encoded_st pwbox_encoded_t;
     26 /** Return a newly allocated pwbox_encoded with all elements set to
     27 * zero.
     28 */
     29 pwbox_encoded_t *pwbox_encoded_new(void);
     30 /** Release all storage held by the pwbox_encoded in 'victim'. (Do
     31 * nothing if 'victim' is NULL.)
     32 */
     33 void pwbox_encoded_free(pwbox_encoded_t *victim);
     34 /** Try to parse a pwbox_encoded from the buffer in 'input', using up
     35 * to 'len_in' bytes from the input buffer. On success, return the
     36 * number of bytes consumed and set *output to the newly allocated
     37 * pwbox_encoded_t. On failure, return -2 if the input appears
     38 * truncated, and -1 if the input is otherwise invalid.
     39 */
     40 ssize_t pwbox_encoded_parse(pwbox_encoded_t **output, const uint8_t *input, const size_t len_in);
     41 /** Return the number of bytes we expect to need to encode the
     42 * pwbox_encoded in 'obj'. On failure, return a negative value. Note
     43 * that this value may be an overestimate, and can even be an
     44 * underestimate for certain unencodeable objects.
     45 */
     46 ssize_t pwbox_encoded_encoded_len(const pwbox_encoded_t *obj);
     47 /** Try to encode the pwbox_encoded from 'input' into the buffer at
     48 * 'output', using up to 'avail' bytes of the output buffer. On
     49 * success, return the number of bytes used. On failure, return -2 if
     50 * the buffer was not long enough, and -1 if the input was invalid.
     51 */
     52 ssize_t pwbox_encoded_encode(uint8_t *output, size_t avail, const pwbox_encoded_t *input);
     53 /** Check whether the internal state of the pwbox_encoded in 'obj' is
     54 * consistent. Return NULL if it is, and a short message if it is not.
     55 */
     56 const char *pwbox_encoded_check(const pwbox_encoded_t *obj);
     57 /** Clear any errors that were set on the object 'obj' by its setter
     58 * functions. Return true iff errors were cleared.
     59 */
     60 int pwbox_encoded_clear_errors(pwbox_encoded_t *obj);
     61 /** Return the value of the fixedbytes0 field of the pwbox_encoded_t
     62 * in 'inp'
     63 */
     64 uint32_t pwbox_encoded_get_fixedbytes0(const pwbox_encoded_t *inp);
     65 /** Set the value of the fixedbytes0 field of the pwbox_encoded_t in
     66 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
     67 * code on 'inp' on failure.
     68 */
     69 int pwbox_encoded_set_fixedbytes0(pwbox_encoded_t *inp, uint32_t val);
     70 /** Return the value of the fixedbytes1 field of the pwbox_encoded_t
     71 * in 'inp'
     72 */
     73 uint32_t pwbox_encoded_get_fixedbytes1(const pwbox_encoded_t *inp);
     74 /** Set the value of the fixedbytes1 field of the pwbox_encoded_t in
     75 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
     76 * code on 'inp' on failure.
     77 */
     78 int pwbox_encoded_set_fixedbytes1(pwbox_encoded_t *inp, uint32_t val);
     79 /** Return the value of the header_len field of the pwbox_encoded_t in
     80 * 'inp'
     81 */
     82 uint8_t pwbox_encoded_get_header_len(const pwbox_encoded_t *inp);
     83 /** Set the value of the header_len field of the pwbox_encoded_t in
     84 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
     85 * code on 'inp' on failure.
     86 */
     87 int pwbox_encoded_set_header_len(pwbox_encoded_t *inp, uint8_t val);
     88 /** Return the length of the dynamic array holding the skey_header
     89 * field of the pwbox_encoded_t in 'inp'.
     90 */
     91 size_t pwbox_encoded_getlen_skey_header(const pwbox_encoded_t *inp);
     92 /** Return the element at position 'idx' of the dynamic array field
     93 * skey_header of the pwbox_encoded_t in 'inp'.
     94 */
     95 uint8_t pwbox_encoded_get_skey_header(pwbox_encoded_t *inp, size_t idx);
     96 /** As pwbox_encoded_get_skey_header, but take and return a const
     97 * pointer
     98 */
     99 uint8_t pwbox_encoded_getconst_skey_header(const pwbox_encoded_t *inp, size_t idx);
    100 /** Change the element at position 'idx' of the dynamic array field
    101 * skey_header of the pwbox_encoded_t in 'inp', so that it will hold
    102 * the value 'elt'.
    103 */
    104 int pwbox_encoded_set_skey_header(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
    105 /** Append a new element 'elt' to the dynamic array field skey_header
    106 * of the pwbox_encoded_t in 'inp'.
    107 */
    108 int pwbox_encoded_add_skey_header(pwbox_encoded_t *inp, uint8_t elt);
    109 /** Return a pointer to the variable-length array field skey_header of
    110 * 'inp'.
    111 */
    112 uint8_t * pwbox_encoded_getarray_skey_header(pwbox_encoded_t *inp);
    113 /** As pwbox_encoded_get_skey_header, but take and return a const
    114 * pointer
    115 */
    116 const uint8_t  * pwbox_encoded_getconstarray_skey_header(const pwbox_encoded_t *inp);
    117 /** Change the length of the variable-length array field skey_header
    118 * of 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on
    119 * success; return -1 and set the error code on 'inp' on failure.
    120 */
    121 int pwbox_encoded_setlen_skey_header(pwbox_encoded_t *inp, size_t newlen);
    122 /** Return the (constant) length of the array holding the iv field of
    123 * the pwbox_encoded_t in 'inp'.
    124 */
    125 size_t pwbox_encoded_getlen_iv(const pwbox_encoded_t *inp);
    126 /** Return the element at position 'idx' of the fixed array field iv
    127 * of the pwbox_encoded_t in 'inp'.
    128 */
    129 uint8_t pwbox_encoded_get_iv(pwbox_encoded_t *inp, size_t idx);
    130 /** As pwbox_encoded_get_iv, but take and return a const pointer
    131 */
    132 uint8_t pwbox_encoded_getconst_iv(const pwbox_encoded_t *inp, size_t idx);
    133 /** Change the element at position 'idx' of the fixed array field iv
    134 * of the pwbox_encoded_t in 'inp', so that it will hold the value
    135 * 'elt'.
    136 */
    137 int pwbox_encoded_set_iv(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
    138 /** Return a pointer to the 16-element array field iv of 'inp'.
    139 */
    140 uint8_t * pwbox_encoded_getarray_iv(pwbox_encoded_t *inp);
    141 /** As pwbox_encoded_get_iv, but take and return a const pointer
    142 */
    143 const uint8_t  * pwbox_encoded_getconstarray_iv(const pwbox_encoded_t *inp);
    144 /** Return the length of the dynamic array holding the data field of
    145 * the pwbox_encoded_t in 'inp'.
    146 */
    147 size_t pwbox_encoded_getlen_data(const pwbox_encoded_t *inp);
    148 /** Return the element at position 'idx' of the dynamic array field
    149 * data of the pwbox_encoded_t in 'inp'.
    150 */
    151 uint8_t pwbox_encoded_get_data(pwbox_encoded_t *inp, size_t idx);
    152 /** As pwbox_encoded_get_data, but take and return a const pointer
    153 */
    154 uint8_t pwbox_encoded_getconst_data(const pwbox_encoded_t *inp, size_t idx);
    155 /** Change the element at position 'idx' of the dynamic array field
    156 * data of the pwbox_encoded_t in 'inp', so that it will hold the
    157 * value 'elt'.
    158 */
    159 int pwbox_encoded_set_data(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
    160 /** Append a new element 'elt' to the dynamic array field data of the
    161 * pwbox_encoded_t in 'inp'.
    162 */
    163 int pwbox_encoded_add_data(pwbox_encoded_t *inp, uint8_t elt);
    164 /** Return a pointer to the variable-length array field data of 'inp'.
    165 */
    166 uint8_t * pwbox_encoded_getarray_data(pwbox_encoded_t *inp);
    167 /** As pwbox_encoded_get_data, but take and return a const pointer
    168 */
    169 const uint8_t  * pwbox_encoded_getconstarray_data(const pwbox_encoded_t *inp);
    170 /** Change the length of the variable-length array field data of 'inp'
    171 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
    172 * -1 and set the error code on 'inp' on failure.
    173 */
    174 int pwbox_encoded_setlen_data(pwbox_encoded_t *inp, size_t newlen);
    175 /** Return the (constant) length of the array holding the hmac field
    176 * of the pwbox_encoded_t in 'inp'.
    177 */
    178 size_t pwbox_encoded_getlen_hmac(const pwbox_encoded_t *inp);
    179 /** Return the element at position 'idx' of the fixed array field hmac
    180 * of the pwbox_encoded_t in 'inp'.
    181 */
    182 uint8_t pwbox_encoded_get_hmac(pwbox_encoded_t *inp, size_t idx);
    183 /** As pwbox_encoded_get_hmac, but take and return a const pointer
    184 */
    185 uint8_t pwbox_encoded_getconst_hmac(const pwbox_encoded_t *inp, size_t idx);
    186 /** Change the element at position 'idx' of the fixed array field hmac
    187 * of the pwbox_encoded_t in 'inp', so that it will hold the value
    188 * 'elt'.
    189 */
    190 int pwbox_encoded_set_hmac(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
    191 /** Return a pointer to the 32-element array field hmac of 'inp'.
    192 */
    193 uint8_t * pwbox_encoded_getarray_hmac(pwbox_encoded_t *inp);
    194 /** As pwbox_encoded_get_hmac, but take and return a const pointer
    195 */
    196 const uint8_t  * pwbox_encoded_getconstarray_hmac(const pwbox_encoded_t *inp);
    197 
    198 
    199 #endif