diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-06-30 09:15:45 -0500 |
---|---|---|
committer | lvh <_@lvh.io> | 2016-06-30 09:15:45 -0500 |
commit | c9c76210fad230995a6155287e8b92c49180eae4 (patch) | |
tree | 6f14f8c5ef8f0cebf0c809b94f0689d4cf52081d | |
parent | 10888813fc8a7e6a4b9cc7713ef1b92db4ad2809 (diff) | |
download | py-bcrypt-git-c9c76210fad230995a6155287e8b92c49180eae4.tar.gz |
Fix alpine (#79)
* we need to define these if they don't exist on any platform
* clean up some warnings
* swap decls to __cplusplus defines
-rw-r--r-- | src/_csrc/portable_endian.h | 16 | ||||
-rw-r--r-- | src/_csrc/pycabcrypt.h | 3 | ||||
-rw-r--r-- | src/_csrc/sha2.h | 8 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/_csrc/portable_endian.h b/src/_csrc/portable_endian.h index e90b203..848803b 100644 --- a/src/_csrc/portable_endian.h +++ b/src/_csrc/portable_endian.h @@ -15,13 +15,21 @@ #if defined(__linux__) || defined(__CYGWIN__) /* Define necessary macros for the header to expose all fields. */ -# define _BSD_SOURCE -# define __USE_BSD -# define _DEFAULT_SOURCE +# if !defined(_BSD_SOURCE) +# define _BSD_SOURCE +# endif +# if !defined(__USE_BSD) +# define __USE_BSD +# endif +# if !defined(_DEFAULT_SOURCE) +# define _DEFAULT_SOURCE +# endif # include <endian.h> # include <features.h> /* See http://linux.die.net/man/3/endian */ -# if !defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 9))) +# if defined(htobe16) && defined(htole16) && defined(be16toh) && defined(le16toh) && defined(htobe32) && defined(htole32) && defined(be32toh) && defined(htole32) && defined(htobe64) && defined(htole64) && defined(be64) && defined(le64) +/* Do nothing. The macros we need already exist. */ +# elif !defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 9))) # include <arpa/inet.h> # if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN) # define htobe16(x) htons(x) diff --git a/src/_csrc/pycabcrypt.h b/src/_csrc/pycabcrypt.h index 0c089e7..c1a8422 100644 --- a/src/_csrc/pycabcrypt.h +++ b/src/_csrc/pycabcrypt.h @@ -14,8 +14,6 @@ typedef unsigned long long uint64_t; typedef uint64_t u_int64_t; #define snprintf _snprintf #define __attribute__(unused) -#define __BEGIN_DECLS -#define __END_DECLS #else #include <stdint.h> #endif @@ -26,3 +24,4 @@ typedef uint64_t u_int64_t; int bcrypt_hashpass(const char *key, const char *salt, char *encrypted, size_t encryptedlen); int encode_base64(char *, const u_int8_t *, size_t); int timingsafe_bcmp(const void *b1, const void *b2, size_t n); +int bcrypt_pbkdf(const char *pass, size_t passlen, const uint8_t *salt, size_t saltlen, uint8_t *key, size_t keylen, unsigned int rounds); diff --git a/src/_csrc/sha2.h b/src/_csrc/sha2.h index e487cfc..31b3830 100644 --- a/src/_csrc/sha2.h +++ b/src/_csrc/sha2.h @@ -60,7 +60,9 @@ typedef struct _SHA2_CTX { u_int8_t buffer[SHA512_BLOCK_LENGTH]; } SHA2_CTX; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif void SHA256Init(SHA2_CTX *); void SHA256Update(SHA2_CTX *, const void *, size_t) __attribute__((__bounded__(__string__,2,3))); @@ -78,6 +80,8 @@ void SHA512Update(SHA2_CTX *, const void *, size_t) __attribute__((__bounded__(__string__,2,3))); void SHA512Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA2_CTX *) __attribute__((__bounded__(__minbytes__,1,SHA512_DIGEST_LENGTH))); -__END_DECLS +#ifdef __cplusplus +} +#endif #endif /* _SHA2_H */ |