summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-12-23 07:43:05 +0000
committerRoger Dingledine <arma@torproject.org>2003-12-23 07:43:05 +0000
commitbc8c6732cb17fbd3d1105d79fbbf02b691bc3576 (patch)
tree165729bde48f4baee4132385b153e57ed63d2e08
parent55a94cd497efab8b41fc7390e657d0856b557e0f (diff)
downloadtor-bc8c6732cb17fbd3d1105d79fbbf02b691bc3576.tar.gz
tor-bc8c6732cb17fbd3d1105d79fbbf02b691bc3576.zip
add crypto_cipher_rewind to reverse crypto_cipher_advance
svn:r957
-rw-r--r--src/common/crypto.c10
-rw-r--r--src/common/crypto.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 73f015f0ec..9ffc9934df 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -808,6 +808,12 @@ int crypto_cipher_decrypt(crypto_cipher_env_t *env, unsigned char *from, unsigne
}
int
+crypto_cipher_rewind(crypto_cipher_env_t *env, long delta)
+{
+ return crypto_cipher_advance(env, -delta);
+}
+
+int
crypto_cipher_advance(crypto_cipher_env_t *env, long delta)
{
if (env->type == CRYPTO_CIPHER_AES_CTR) {
@@ -841,8 +847,8 @@ crypto_new_digest_env(int type)
void
crypto_free_digest_env(crypto_digest_env_t *digest) {
- assert(digest);
- tor_free(digest);
+ if(digest)
+ free(digest);
}
void
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 0ec4e92456..4ada97e519 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -92,6 +92,7 @@ int crypto_cipher_encrypt(crypto_cipher_env_t *env, unsigned char *from, unsigne
int crypto_cipher_decrypt(crypto_cipher_env_t *env, unsigned char *from, unsigned int fromlen, unsigned char *to);
/* only implemented for CRYPTO_CIPHER_AES_CTR */
+int crypto_cipher_rewind(crypto_cipher_env_t *env, long delta);
int crypto_cipher_advance(crypto_cipher_env_t *env, long delta);
/* convenience function: wraps crypto_create_crypto_env, set_key, set_iv, and init. */