aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/crypto.c16
-rw-r--r--src/common/crypto.h8
2 files changed, 13 insertions, 11 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 3520d7af0..8a47306d3 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -818,7 +818,6 @@ crypto_cipher_advance(crypto_cipher_env_t *env, long delta)
}
}
-
/* SHA-1 */
int crypto_SHA_digest(const unsigned char *m, int len, unsigned char *digest)
{
@@ -833,8 +832,9 @@ struct crypto_digest_env_t {
crypto_digest_env_t *
crypto_digest_new_env(int type)
{
+ crypto_digest_env_t *r;
assert(type == CRYPTO_SHA1_DIGEST);
- crypto_digest_env_t *r = tor_malloc(sizeof(crypto_digest_env_t));
+ r = tor_malloc(sizeof(crypto_digest_env_t));
SHA1_Init(&r->d);
return r;
}
@@ -844,16 +844,18 @@ crypto_digest_free(crypto_digest_env_t *digest) {
assert(digest);
tor_free(digest);
}
+
void
crypto_digest_add_bytes(crypto_digest_env_t *digest, const char *data,
- size_t len)
+ size_t len)
{
assert(digest);
assert(data);
SHA1_Update(&digest->d, (void*)data, len);
}
+
void crypto_digest_get_digest(crypto_digest_env_t *digest,
- char *out, size_t out_len)
+ char *out, size_t out_len)
{
static char r[SHA_DIGEST_LENGTH];
assert(digest && out);
@@ -863,17 +865,18 @@ void crypto_digest_get_digest(crypto_digest_env_t *digest,
}
crypto_digest_env_t *
-crypto_digest_copy(const crypto_digest_env_t *digest)
+crypto_digest_dup(const crypto_digest_env_t *digest)
{
crypto_digest_env_t *r;
assert(digest);
r = tor_malloc(sizeof(crypto_digest_env_t));
memcpy(r,digest,sizeof(crypto_digest_env_t));
+ return r;
}
void
crypto_digest_assign(crypto_digest_env_t *into,
- const crypto_digest_env_t *from)
+ const crypto_digest_env_t *from)
{
assert(into && from);
memcpy(into,from,sizeof(crypto_digest_env_t));
@@ -883,7 +886,6 @@ crypto_digest_assign(crypto_digest_env_t *into,
static BIGNUM *dh_param_p = NULL;
static BIGNUM *dh_param_g = NULL;
-
static void init_dh_param() {
BIGNUM *p, *g;
int r;
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 6d26cfa1e..1b072839f 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -102,12 +102,12 @@ int crypto_SHA_digest(const unsigned char *m, int len, unsigned char *digest);
crypto_digest_env_t *crypto_new_digest_env(int type);
void crypto_digest_free(crypto_digest_env_t *digest);
void crypto_digest_add_bytes(crypto_digest_env_t *digest, const char *data,
- size_t len);
+ size_t len);
void crypto_digest_get_digest(crypto_digest_env_t *digest,
- char *out, size_t out_len);
-crypto_digest_env_t *crypto_digest_copy(const crypto_digest_env_t *digest);
+ char *out, size_t out_len);
+crypto_digest_env_t *crypto_digest_dup(const crypto_digest_env_t *digest);
void crypto_digest_assign(crypto_digest_env_t *into,
- const crypto_digest_env_t *from);
+ const crypto_digest_env_t *from);
/* random numbers */
int crypto_seed_rng();