diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | endian.h | 13 | ||||
-rw-r--r-- | sand-leek.c | 4 |
3 files changed, 17 insertions, 2 deletions
@@ -3,6 +3,8 @@ LDFLAGS += -lssl -lcrypto -lpthread all: sand-leek +sand-leek.o: endian.h onion_base32.h key_update.h + sand-leek: sand-leek.o onion_base32.o key_update.o $(CC) -o $@ $^ $(LDFLAGS) diff --git a/endian.h b/endian.h new file mode 100644 index 0000000..6ebda83 --- /dev/null +++ b/endian.h @@ -0,0 +1,13 @@ +#ifndef SAND_LEEK_ENDIAN_H +#define SAND_LEEK_ENDIAN_H + +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define sl_htobe32(x) (x) +#else +# define sl_htobe32(x) (((x & 0x000000FF) << 24) | \ + ((x & 0xFF000000) >> 24)) | \ + ((x & 0x0000FF00) << 8) | \ + ((x & 0x00FF0000) >> 8) +#endif + +#endif /* ifndef SAND_LEEK_ENDIAN_H */ diff --git a/sand-leek.c b/sand-leek.c index 7c5ea29..97b9b1d 100644 --- a/sand-leek.c +++ b/sand-leek.c @@ -6,12 +6,12 @@ #include <semaphore.h> #include <errno.h> #include <string.h> -#include <endian.h> #include <openssl/rsa.h> #include <openssl/sha.h> #include <openssl/pem.h> #include <openssl/err.h> +#include "endian.h" #include "onion_base32.h" #include "key_update.h" @@ -91,7 +91,7 @@ work(void *arg) { while (e < EXPONENT_MAX) { memcpy(&working_sha_c, &sha_c, sizeof(SHA_CTX)); - e_big_endian = htobe32(e); + e_big_endian = sl_htobe32(e); SHA1_Update(&working_sha_c, &e_big_endian, EXPONENT_SIZE_BYTES); SHA1_Final((unsigned char*)&sha, &working_sha_c); |