diff --git a/crypto/sig_picnic/macos_specific_endian.h b/crypto/sig_picnic/macos_specific_endian.h new file mode 100644 index 0000000000000000000000000000000000000000..f7b6756a062fb8aced2f09687172b90f77f75106 --- /dev/null +++ b/crypto/sig_picnic/macos_specific_endian.h @@ -0,0 +1,32 @@ +#ifndef MACOS_SPECIFIC_ENDIAN_H +#define MACOS_SPECIFIC_ENDIAN_H + +/** compatibility header for endian.h + * This is a simple compatibility shim to convert + * BSD/Linux endian macros to the Mac OS X equivalents. + * It is public domain. + * */ + +#ifndef __APPLE__ + #warning "This header file (endian.h) is MacOS X specific.\n" +#endif /* __APPLE__ */ + +#include <machine/endian.h> +#include <libkern/OSByteOrder.h> + +#define htobe16(x) OSSwapHostToBigInt16(x) +#define htole16(x) OSSwapHostToLittleInt16(x) +#define be16toh(x) OSSwapBigToHostInt16(x) +#define le16toh(x) OSSwapLittleToHostInt16(x) + +#define htobe32(x) OSSwapHostToBigInt32(x) +#define htole32(x) OSSwapHostToLittleInt32(x) +#define be32toh(x) OSSwapBigToHostInt32(x) +#define le32toh(x) OSSwapLittleToHostInt32(x) + +#define htobe64(x) OSSwapHostToBigInt64(x) +#define htole64(x) OSSwapHostToLittleInt64(x) +#define be64toh(x) OSSwapBigToHostInt64(x) +#define le64toh(x) OSSwapLittleToHostInt64(x) + +#endif // MACOS_SPECIFIC_ENDIAN_H diff --git a/crypto/sig_picnic/picnic_impl.c b/crypto/sig_picnic/picnic_impl.c index e1061f03fd7fc8663e1cbf61596d90ab47eb1bd8..990a6dae471569046ef4b86d4258d11630e2f8a6 100644 --- a/crypto/sig_picnic/picnic_impl.c +++ b/crypto/sig_picnic/picnic_impl.c @@ -20,6 +20,8 @@ #if defined (__WIN32) #include <Windows.h> #include <bcrypt.h> +#elif defined (__APPLE__) + #include "macos_specific_endian.h" #else #include <endian.h> #endif diff --git a/crypto/sig_picnic/sig_picnic.pri b/crypto/sig_picnic/sig_picnic.pri index 52fd38176d6dc903300e9f32f5661674f5b0b64d..f95cfdd7a48fa9ea60d914fe4dbeac2d0eec57ad 100644 --- a/crypto/sig_picnic/sig_picnic.pri +++ b/crypto/sig_picnic/sig_picnic.pri @@ -3,8 +3,9 @@ HEADERS += $$PWD/hash.h \ $$PWD/picnic.h \ $$PWD/picnic_impl.h \ $$PWD/picnic_types.h \ - $$PWD/platform.h \ + $$PWD/platform.h +macos { HEADERS += $$PWD/macos_specific_endian.h } SOURCES += $$PWD/hash.c \ $$PWD/lowmc_constants.c \