13 #ifndef TOR_CRYPTO_DIGEST_H
14 #define TOR_CRYPTO_DIGEST_H
23 #define BASE32_DIGEST_LEN 32
26 #define BASE64_DIGEST_LEN 27
29 #define BASE64_DIGEST256_LEN 43
32 #define BASE64_DIGEST512_LEN 86
35 #define HEX_DIGEST_LEN 40
37 #define HEX_DIGEST256_LEN 64
39 #define HEX_DIGEST512_LEN 128
52 #define N_DIGEST_ALGORITHMS (DIGEST_SHA3_512+1)
58 #define N_COMMON_DIGEST_ALGORITHMS (DIGEST_SHA256+1)
65 #define DIGEST_CHECKPOINT_BYTES (SIZEOF_VOID_P + 512)
72 unsigned int bytes_used;
112 void crypto_digest_smartlist_prefix(
char *digest_out,
size_t len_out,
117 void crypto_digest_smartlist(
char *digest_out,
size_t len_out,
130 #define crypto_digest_free(d) \
131 FREE_AND_NULL(crypto_digest_t, crypto_digest_free_, (d))
135 char *out,
size_t out_len);
144 const char *key,
size_t key_len,
145 const char *msg,
size_t msg_len);
147 const uint8_t *key,
size_t key_len,
148 const uint8_t *msg,
size_t msg_len);
158 #define crypto_xof_free(xof) \
159 FREE_AND_NULL(crypto_xof_t, crypto_xof_free_, (xof))
160 void crypto_xof(uint8_t *output,
size_t output_len,
161 const uint8_t *input,
size_t input_len);
163 #ifdef TOR_UNIT_TESTS
void crypto_mac_sha3_256(uint8_t *mac_out, size_t len_out, const uint8_t *key, size_t key_len, const uint8_t *msg, size_t msg_len)
size_t crypto_digest_algorithm_get_length(digest_algorithm_t alg)
void crypto_digest_checkpoint(crypto_digest_checkpoint_t *checkpoint, const crypto_digest_t *digest)
int crypto_digest512(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
int crypto_digest256(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
#define N_COMMON_DIGEST_ALGORITHMS
void crypto_xof(uint8_t *output, size_t output_len, const uint8_t *input, size_t input_len)
#define DIGEST_CHECKPOINT_BYTES
void crypto_hmac_sha256(char *hmac_out, const char *key, size_t key_len, const char *msg, size_t msg_len)
void crypto_digest_restore(crypto_digest_t *digest, const crypto_digest_checkpoint_t *checkpoint)
void crypto_xof_squeeze_bytes(crypto_xof_t *xof, uint8_t *out, size_t len)
void crypto_digest_get_digest(crypto_digest_t *digest, char *out, size_t out_len)
void crypto_digest_assign(crypto_digest_t *into, const crypto_digest_t *from)
int crypto_common_digests(common_digests_t *ds_out, const char *m, size_t len)
crypto_xof_t * crypto_xof_new(void)
void crypto_xof_add_bytes(crypto_xof_t *xof, const uint8_t *data, size_t len)
crypto_digest_t * crypto_digest256_new(digest_algorithm_t algorithm)
crypto_digest_t * crypto_digest_dup(const crypto_digest_t *digest)
int crypto_digest(char *digest, const char *m, size_t len)
const char * crypto_digest_algorithm_get_name(digest_algorithm_t alg)
crypto_digest_t * crypto_digest_new(void)
void crypto_xof_free_(crypto_xof_t *xof)
void crypto_digest_free_(crypto_digest_t *digest)
void crypto_digest_add_bytes(crypto_digest_t *digest, const char *data, size_t len)
int crypto_digest_algorithm_parse_name(const char *name)
crypto_digest_t * crypto_digest512_new(digest_algorithm_t algorithm)
Definitions for common sizes of cryptographic digests.
Headers for util_malloc.c.
uint8_t mem[DIGEST_CHECKPOINT_BYTES]
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Integer definitions used throughout Tor.