mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Hide crypto_digest_t again and use an accessor for tests.
This commit is contained in:
parent
70d08f764d
commit
f35f52e869
@ -1839,6 +1839,33 @@ crypto_digest_algorithm_get_length(digest_algorithm_t alg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef TOR_UNIT_TESTS
|
||||||
|
|
||||||
|
digest_algorithm_t
|
||||||
|
crypto_digest_get_algorithm(crypto_digest_t *digest)
|
||||||
|
{
|
||||||
|
tor_assert(digest);
|
||||||
|
|
||||||
|
return digest->algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of bytes we need to malloc in order to get a
|
* Return the number of bytes we need to malloc in order to get a
|
||||||
* crypto_digest_t for <b>alg</b>, or the number of bytes we need to wipe
|
* crypto_digest_t for <b>alg</b>, or the number of bytes we need to wipe
|
||||||
|
@ -339,21 +339,6 @@ void crypto_add_spaces_to_fp(char *out, size_t outlen, const char *in);
|
|||||||
|
|
||||||
#ifdef CRYPTO_PRIVATE
|
#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_force_rand_ssleay(void);
|
||||||
STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len);
|
STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len);
|
||||||
|
|
||||||
@ -365,6 +350,7 @@ extern int break_strongest_rng_fallback;
|
|||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
void crypto_pk_assign_(crypto_pk_t *dest, const crypto_pk_t *src);
|
void crypto_pk_assign_(crypto_pk_t *dest, const crypto_pk_t *src);
|
||||||
|
digest_algorithm_t crypto_digest_get_algorithm(crypto_digest_t *digest);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -188,8 +188,10 @@ test_e2e_rend_circuit_setup_legacy(void *arg)
|
|||||||
tt_int_op(retval, OP_EQ, 1);
|
tt_int_op(retval, OP_EQ, 1);
|
||||||
|
|
||||||
/* Check the digest algo */
|
/* Check the digest algo */
|
||||||
tt_int_op(or_circ->cpath->f_digest->algorithm, OP_EQ, DIGEST_SHA1);
|
tt_int_op(crypto_digest_get_algorithm(or_circ->cpath->f_digest),
|
||||||
tt_int_op(or_circ->cpath->b_digest->algorithm, OP_EQ, DIGEST_SHA1);
|
OP_EQ, DIGEST_SHA1);
|
||||||
|
tt_int_op(crypto_digest_get_algorithm(or_circ->cpath->b_digest),
|
||||||
|
OP_EQ, DIGEST_SHA1);
|
||||||
tt_assert(or_circ->cpath->f_crypto);
|
tt_assert(or_circ->cpath->f_crypto);
|
||||||
tt_assert(or_circ->cpath->b_crypto);
|
tt_assert(or_circ->cpath->b_crypto);
|
||||||
|
|
||||||
@ -255,8 +257,10 @@ test_e2e_rend_circuit_setup(void *arg)
|
|||||||
tt_int_op(retval, OP_EQ, 1);
|
tt_int_op(retval, OP_EQ, 1);
|
||||||
|
|
||||||
/* Check that the crypt path has prop224 algorithm parameters */
|
/* Check that the crypt path has prop224 algorithm parameters */
|
||||||
tt_int_op(or_circ->cpath->f_digest->algorithm, OP_EQ, DIGEST_SHA3_256);
|
tt_int_op(crypto_digest_get_algorithm(or_circ->cpath->f_digest),
|
||||||
tt_int_op(or_circ->cpath->b_digest->algorithm, OP_EQ, DIGEST_SHA3_256);
|
OP_EQ, DIGEST_SHA3_256);
|
||||||
|
tt_int_op(crypto_digest_get_algorithm(or_circ->cpath->b_digest),
|
||||||
|
OP_EQ, DIGEST_SHA3_256);
|
||||||
tt_assert(or_circ->cpath->f_crypto);
|
tt_assert(or_circ->cpath->f_crypto);
|
||||||
tt_assert(or_circ->cpath->b_crypto);
|
tt_assert(or_circ->cpath->b_crypto);
|
||||||
|
|
||||||
|
@ -301,8 +301,10 @@ test_e2e_rend_circuit_setup(void *arg)
|
|||||||
tt_int_op(retval, OP_EQ, 1);
|
tt_int_op(retval, OP_EQ, 1);
|
||||||
|
|
||||||
/* Check the digest algo */
|
/* Check the digest algo */
|
||||||
tt_int_op(or_circ->cpath->f_digest->algorithm, OP_EQ, DIGEST_SHA3_256);
|
tt_int_op(crypto_digest_get_algorithm(or_circ->cpath->f_digest),
|
||||||
tt_int_op(or_circ->cpath->b_digest->algorithm, OP_EQ, DIGEST_SHA3_256);
|
OP_EQ, DIGEST_SHA3_256);
|
||||||
|
tt_int_op(crypto_digest_get_algorithm(or_circ->cpath->b_digest),
|
||||||
|
OP_EQ, DIGEST_SHA3_256);
|
||||||
tt_assert(or_circ->cpath->f_crypto);
|
tt_assert(or_circ->cpath->f_crypto);
|
||||||
tt_assert(or_circ->cpath->b_crypto);
|
tt_assert(or_circ->cpath->b_crypto);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user