diff options
author | George Kadianakis <desnacked@riseup.net> | 2017-05-02 16:33:49 +0300 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-07-07 11:12:26 -0400 |
commit | 43a73f6eb648632552a20dd17f5736550df75e10 (patch) | |
tree | 54cf869075bc916701c84c83dca3a3b99ead4d4f /src/common/crypto.h | |
parent | 9ff5613a340f220a202d3f0332f091d812068881 (diff) | |
download | tor-43a73f6eb648632552a20dd17f5736550df75e10.tar.gz tor-43a73f6eb648632552a20dd17f5736550df75e10.zip |
test: Crypto groundwork for e2e circuit unittests.
- Move some crypto structures so that they are visible by tests.
- Introduce a func to count number of hops in cpath which will be used
by the tests.
- Mark a function as mockable.
Diffstat (limited to 'src/common/crypto.h')
-rw-r--r-- | src/common/crypto.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/crypto.h b/src/common/crypto.h index c70d91c262..3766830f73 100644 --- a/src/common/crypto.h +++ b/src/common/crypto.h @@ -20,6 +20,9 @@ #include "testsupport.h" #include "compat.h" +#include <openssl/engine.h> +#include "keccak-tiny/keccak-tiny.h" + /* Macro to create an arbitrary OpenSSL version number as used by OPENSSL_VERSION_NUMBER or SSLeay(), since the actual numbers are a bit hard @@ -335,6 +338,22 @@ struct dh_st *crypto_dh_get_dh_(crypto_dh_t *dh); void crypto_add_spaces_to_fp(char *out, size_t outlen, const char *in); #ifdef CRYPTO_PRIVATE + +/** Intermediate information about the digest of a stream of data. */ +struct crypto_digest_t { + digest_algorithm_t algorithm; /**< Which algorithm is in use? */ + /** State for the digest we're using. Only one member of the + * union is usable, depending on the value of <b>algorithm</b>. Note also + * that space for other members might not even be allocated! + */ + union { + SHA_CTX sha1; /**< state for SHA1 */ + SHA256_CTX sha2; /**< state for SHA256 */ + SHA512_CTX sha512; /**< state for SHA512 */ + keccak_state sha3; /**< state for SHA3-[256,512] */ + } d; +}; + STATIC int crypto_force_rand_ssleay(void); STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len); |