diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-08-09 11:22:27 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-08-09 12:04:18 +0200 |
commit | ecf5ecc70e8d71449a1b8d40496e4906e65457ea (patch) | |
tree | 0b40f781d3d49235eeae7b1f2e970eb454c62464 /libpiano | |
parent | bc3c92cb0e5a219d8f94a8bee6765885dbfc4333 (diff) | |
download | pianobar-ecf5ecc70e8d71449a1b8d40496e4906e65457ea.tar.gz pianobar-ecf5ecc70e8d71449a1b8d40496e4906e65457ea.tar.bz2 pianobar-ecf5ecc70e8d71449a1b8d40496e4906e65457ea.zip |
Support for big endian machines
A few byteswaps replaced by conditional byteswaps. Thanks to Andrew Peng
for providing access to a powerpc machine.
Diffstat (limited to 'libpiano')
-rw-r--r-- | libpiano/src/crypt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libpiano/src/crypt.c b/libpiano/src/crypt.c index ef0b2dc..e94a54d 100644 --- a/libpiano/src/crypt.c +++ b/libpiano/src/crypt.c @@ -25,6 +25,7 @@ THE SOFTWARE. #include <stdio.h> #include <stdlib.h> #include <stdint.h> +#include <arpa/inet.h> #include "crypt_key_output.h" #include "crypt_key_input.h" @@ -35,6 +36,9 @@ THE SOFTWARE. (((x) << 8) & 0x00ff0000) | \ (((x) << 24) & 0xff000000)) +#define hostToBigEndian32(x) htonl(x) +#define bigToHostEndian32(x) ntohl(x) + /* decrypt hex-encoded, blowfish-crypted string: decode 2 hex-encoded blocks, * decrypt, byteswap * @param hex string @@ -98,8 +102,8 @@ unsigned char *PianoDecryptString (const unsigned char *strInput) { r ^= in_key_p [1]; l ^= in_key_p [0]; - *(iDecrypt-2) = byteswap32 (l); - *(iDecrypt-1) = byteswap32 (r); + *(iDecrypt-2) = bigToHostEndian32 (l); + *(iDecrypt-1) = bigToHostEndian32 (r); intsDecoded = 0; } @@ -142,8 +146,8 @@ unsigned char *PianoEncryptString (const unsigned char *strInput) { register uint32_t l, r; int i; - l = byteswap32 (*blockPtr); - r = byteswap32 (*(blockPtr+1)); + l = hostToBigEndian32 (*blockPtr); + r = hostToBigEndian32 (*(blockPtr+1)); /* encrypt blocks */ for (i = 0; i < out_key_n; i++) { |