[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [obfsproxy/master] Killed some magic numbers and replaced them with SHA256_LENGTH.
commit 4f55412fbf663977faf26847f6425ce5e4ea2f7b
Author: George Kadianakis <desnacked@xxxxxxxxx>
Date: Tue May 24 23:52:10 2011 +0200
Killed some magic numbers and replaced them with SHA256_LENGTH.
---
src/protocols/obfs2.c | 4 ++--
src/protocols/obfs2.h | 1 -
src/protocols/obfs2_crypt.c | 4 ++--
src/protocols/obfs2_crypt.h | 2 ++
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/protocols/obfs2.c b/src/protocols/obfs2.c
index 1377dfe..3490d0e 100644
--- a/src/protocols/obfs2.c
+++ b/src/protocols/obfs2.c
@@ -74,7 +74,7 @@ derive_key(void *s, const char *keytype)
obfs2_state_t *state = s;
crypt_t *cryptstate;
- uchar buf[32];
+ uchar buf[SHA256_LENGTH];
digest_t *c = digest_new();
digest_update(c, (uchar*)keytype, strlen(keytype));
if (seed_nonzero(state->initiator_seed))
@@ -99,7 +99,7 @@ derive_padding_key(void *s, const uchar *seed,
obfs2_state_t *state = s;
crypt_t *cryptstate;
- uchar buf[32];
+ uchar buf[SHA256_LENGTH];
digest_t *c = digest_new();
digest_update(c, (uchar*)keytype, strlen(keytype));
if (seed_nonzero(seed))
diff --git a/src/protocols/obfs2.h b/src/protocols/obfs2.h
index bc8a22d..1f9f31d 100644
--- a/src/protocols/obfs2.h
+++ b/src/protocols/obfs2.h
@@ -15,7 +15,6 @@ struct evbuffer;
struct protocol_t;
struct protocol_params_t;
-#define SHA256_LENGTH 32
#define SHARED_SECRET_LENGTH SHA256_LENGTH
int obfs2_init(void);
diff --git a/src/protocols/obfs2_crypt.c b/src/protocols/obfs2_crypt.c
index 0121c93..50d094c 100644
--- a/src/protocols/obfs2_crypt.c
+++ b/src/protocols/obfs2_crypt.c
@@ -109,7 +109,7 @@ digest_update(digest_t *d, const uchar *buf, size_t len)
size_t
digest_getdigest(digest_t *d, uchar *buf, size_t len)
{
- uchar tmp[32];
+ uchar tmp[SHA256_LENGTH];
int n = 32;
SHA256_Final(tmp, &d->ctx);
if (len < 32)
@@ -137,7 +137,7 @@ digest_update(digest_t *d, const uchar *buf, size_t len)
size_t
digest_getdigest(digest_t *d, uchar *buf, size_t len)
{
- uchar tmp[32];
+ uchar tmp[SHA256_LENGTH];
int n = 32;
sha256_done(&d->ctx, tmp);
if (len < 32)
diff --git a/src/protocols/obfs2_crypt.h b/src/protocols/obfs2_crypt.h
index c9841d8..ef279e9 100644
--- a/src/protocols/obfs2_crypt.h
+++ b/src/protocols/obfs2_crypt.h
@@ -10,6 +10,8 @@
#include <sys/types.h>
+#define SHA256_LENGTH 32
+
/* Stream cipher state */
typedef struct crypt_t crypt_t;
/* Digest state */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits