diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-03-31 02:07:38 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-03-31 02:07:38 +0000 |
commit | 6ea61d5e0dd7a5990ab2a5a8198cef425718f81f (patch) | |
tree | 7ed4d3dda872d0caa280242dfad8eda471f6d83c /src/common | |
parent | 670aeb6c8d894cb99a809fd7cc4f516cd0e54933 (diff) | |
download | tor-6ea61d5e0dd7a5990ab2a5a8198cef425718f81f.tar.gz tor-6ea61d5e0dd7a5990ab2a5a8198cef425718f81f.zip |
Parse and generate service descriptors
svn:r1403
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/crypto.c | 1 | ||||
-rw-r--r-- | src/common/util.h | 27 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index e7d4de4642..086848976a 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -569,6 +569,7 @@ int crypto_pk_cmp_keys(crypto_pk_env_t *a, crypto_pk_env_t *b) { } } +/* return the size of the public key modulus in 'env', in bytes. */ int crypto_pk_keysize(crypto_pk_env_t *env) { assert(env && env->key); diff --git a/src/common/util.h b/src/common/util.h index 862a657e72..072929abe3 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -49,13 +49,36 @@ void tor_strlower(char *s); */ #define get_uint16(cp) (*(uint16_t*)(cp)) #define get_uint32(cp) (*(uint32_t*)(cp)) -#define set_uint16(cp,v) do { *(uint16_t)(cp) = (v) } while (0) -#define set_uint32(cp,v) do { *(uint32_t)(cp) = (v) } while (0) +#define set_uint16(cp,v) do { *(uint16_t*)(cp) = (v); } while (0) +#define set_uint32(cp,v) do { *(uint32_t*)(cp) = (v); } while (0) #else +#if 1 uint16_t get_uint16(char *cp); uint32_t get_uint32(char *cp); void set_uint16(char *cp, uint16_t v); void set_uint32(char *cp, uint32_t v); +#else +#define get_uint16(cp) \ + ( ((*(((uint8_t*)(cp))+0))<<8) + \ + ((*(((uint8_t*)(cp))+1)) ) ) +#define get_uint32(cp) \ + ( ((*(((uint8_t*)(cp))+0))<<24) + \ + ((*(((uint8_t*)(cp))+1))<<16) + \ + ((*(((uint8_t*)(cp))+2))<<8 ) + \ + ((*(((uint8_t*)(cp))+3)) ) ) +#define set_uint16(cp,v) \ + do { \ + *(((uint8_t*)(cp))+0) = (v >> 8)&0xff; \ + *(((uint8_t*)(cp))+1) = (v >> 0)&0xff; \ + } while (0) +#define set_uint32(cp,v) \ + do { \ + *(((uint8_t*)(cp))+0) = (v >> 24)&0xff; \ + *(((uint8_t*)(cp))+1) = (v >> 16)&0xff; \ + *(((uint8_t*)(cp))+2) = (v >> 8)&0xff; \ + *(((uint8_t*)(cp))+3) = (v >> 0)&0xff; \ + } while (0) +#endif #endif typedef struct { |