13 #ifndef TOR_CRYPTO_DIGEST_H 14 #define TOR_CRYPTO_DIGEST_H 18 #include "container.h" 25 #define DIGEST256_LEN 32 27 #define DIGEST512_LEN 64 31 #define BASE32_DIGEST_LEN 32 34 #define BASE64_DIGEST_LEN 27 37 #define BASE64_DIGEST256_LEN 43 40 #define BASE64_DIGEST512_LEN 86 43 #define HEX_DIGEST_LEN 40 45 #define HEX_DIGEST256_LEN 64 47 #define HEX_DIGEST512_LEN 128 56 #define N_DIGEST_ALGORITHMS (DIGEST_SHA3_512+1) 57 #define N_COMMON_DIGEST_ALGORITHMS (DIGEST_SHA256+1) 59 #define DIGEST_CHECKPOINT_BYTES (SIZEOF_VOID_P + 512) 63 uint8_t mem[DIGEST_CHECKPOINT_BYTES];
84 digest_algorithm_t algorithm);
86 digest_algorithm_t algorithm);
92 digest_algorithm_t alg);
95 digest_algorithm_t alg);
103 #define crypto_digest_free(d) \ 104 FREE_AND_NULL(crypto_digest_t, crypto_digest_free_, (d)) 108 char *out,
size_t out_len);
111 const crypto_digest_t *digest);
115 const crypto_digest_t *from);
117 const char *key,
size_t key_len,
118 const char *msg,
size_t msg_len);
120 const uint8_t *key,
size_t key_len,
121 const uint8_t *msg,
size_t msg_len);
128 #define crypto_xof_free(xof) \ 129 FREE_AND_NULL(crypto_xof_t, crypto_xof_free_, (xof)) 131 #ifdef TOR_UNIT_TESTS 132 digest_algorithm_t crypto_digest_get_algorithm(crypto_digest_t *digest);
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)
Definition: crypto_digest.c:508
crypto_digest_t * crypto_digest_dup(const crypto_digest_t *digest)
Definition: crypto_digest.c:401
void crypto_digest_smartlist_prefix(char *digest_out, size_t len_out, const char *prepend, const smartlist_t *lst, const char *append, digest_algorithm_t alg)
Definition: crypto_digest.c:467
Definition: crypto_digest.h:74
void crypto_digest_get_digest(crypto_digest_t *digest, char *out, size_t out_len)
Definition: crypto_digest.c:350
int crypto_digest(char *digest, const char *m, size_t len)
Definition: crypto_digest.c:35
void crypto_digest_smartlist(char *digest_out, size_t len_out, const smartlist_t *lst, const char *append, digest_algorithm_t alg)
Definition: crypto_digest.c:452
void crypto_xof_free_(crypto_xof_t *xof)
Definition: crypto_digest.c:576
void crypto_digest_checkpoint(crypto_digest_checkpoint_t *checkpoint, const crypto_digest_t *digest)
Definition: crypto_digest.c:412
crypto_digest_t * crypto_digest256_new(digest_algorithm_t algorithm)
Definition: crypto_digest.c:277
void crypto_digest_add_bytes(crypto_digest_t *digest, const char *data, size_t len)
Definition: crypto_digest.c:310
Definition: container.h:18
Header file to define uint32_t and friends.
crypto_xof_t * crypto_xof_new(void)
Definition: crypto_digest.c:545
void crypto_digest_free_(crypto_digest_t *digest)
Definition: crypto_digest.c:295
void crypto_xof_add_bytes(crypto_xof_t *xof, const uint8_t *data, size_t len)
Definition: crypto_digest.c:558
int crypto_digest_algorithm_parse_name(const char *name)
Definition: crypto_digest.c:133
const char * crypto_digest_algorithm_get_name(digest_algorithm_t alg)
Definition: crypto_digest.c:109
struct crypto_digest_checkpoint_t crypto_digest_checkpoint_t
Definition: crypto_digest.c:535
void crypto_hmac_sha256(char *hmac_out, const char *key, size_t key_len, const char *msg, size_t msg_len)
Definition: crypto_digest.c:489
void crypto_digest_restore(crypto_digest_t *digest, const crypto_digest_checkpoint_t *checkpoint)
Definition: crypto_digest.c:424
#define DIGEST256_LEN
Definition: crypto_digest.h:25
Definition: crypto_digest.h:62
size_t crypto_digest_algorithm_get_length(digest_algorithm_t alg)
Definition: crypto_digest.c:151
void crypto_xof_squeeze_bytes(crypto_xof_t *xof, uint8_t *out, size_t len)
Definition: crypto_digest.c:568
int crypto_common_digests(common_digests_t *ds_out, const char *m, size_t len)
Definition: crypto_digest.c:95
void crypto_digest_assign(crypto_digest_t *into, const crypto_digest_t *from)
Definition: crypto_digest.c:436
crypto_digest_t * crypto_digest512_new(digest_algorithm_t algorithm)
Definition: crypto_digest.c:286
int crypto_digest256(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
Definition: crypto_digest.c:48
crypto_digest_t * crypto_digest_new(void)
Definition: crypto_digest.c:265
Definition: crypto_digest.c:171
int crypto_digest512(char *digest, const char *m, size_t len, digest_algorithm_t algorithm)
Definition: crypto_digest.c:71