diff --git a/SConstruct b/SConstruct index 32f2b4bb..a7c148d4 100644 --- a/SConstruct +++ b/SConstruct @@ -138,6 +138,12 @@ class FreelanEnvironment(Environment): self.Append(LDFLAGS=['-L/usr/local/lib']) self.Append(LIBPATH=['/usr/local/lib']) + if sys.platform.startswith('openbsd'): + self.Append(CXXFLAGS=['-I/usr/local/include', '-pthread', '-Wno-shadow', '-Wno-nested-anon-types', '-Wno-unused-parameter', '-Wno-unused-local-typedef']) + self.Append(CFLAGS=['-I/usr/local/include', 'pthread', '-Wno-shadow', '-Wno-nested-anon-types', '-Wno-unused-parameter', '-Wno-unused-local-typedef']) + self.Append(LDFLAGS=['-L/usr/local/lib']) + self.Append(LIBPATH=['/usr/local/lib']) + if sys.platform.startswith('netbsd'): self.Append(CXXFLAGS=['-I/usr/pkg/include', '-Wno-shadow']) self.Append(CFLAGS=['-I/usr/pkg/include', '-Wno-shadow']) diff --git a/apps/freelan/SConscript b/apps/freelan/SConscript index 64956bdd..c275768d 100644 --- a/apps/freelan/SConscript +++ b/apps/freelan/SConscript @@ -21,7 +21,7 @@ libraries = [ 'crypto', ] -if sys.platform.startswith('darwin'): +if sys.platform.startswith('darwin') or sys.platform.startswith('openbsd'): libraries.extend([ 'boost_thread-mt', ]) @@ -47,6 +47,10 @@ else: 'pthread', 'c++', ]) + if sys.platform.startswith('openbsd'): + libraries.extend([ + 'iconv', + ]) if env.mongoose == 'yes': libraries.extend([ diff --git a/apps/freelan/src/posix/pid_file.cpp b/apps/freelan/src/posix/pid_file.cpp index c8e48bc9..6f660dfd 100644 --- a/apps/freelan/src/posix/pid_file.cpp +++ b/apps/freelan/src/posix/pid_file.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include #include diff --git a/libs/cryptoplus/include/cryptoplus/asn1/string.hpp b/libs/cryptoplus/include/cryptoplus/asn1/string.hpp index 1ede7677..6ee51ecc 100644 --- a/libs/cryptoplus/include/cryptoplus/asn1/string.hpp +++ b/libs/cryptoplus/include/cryptoplus/asn1/string.hpp @@ -256,10 +256,10 @@ namespace cryptoplus } inline const unsigned char* string::data() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L - return ASN1_STRING_data(ptr().get()); -#else +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) return ASN1_STRING_get0_data(ptr().get()); +#else + return ASN1_STRING_data(ptr().get()); #endif } inline void string::set_data(const void* _data, size_t data_len) const @@ -299,7 +299,7 @@ namespace cryptoplus } inline int compare(const string& lhs, const string& rhs) { -#if OPENSSL_VERSION_NUMBER >= 0x01000000 +#if OPENSSL_VERSION_NUMBER >= 0x01000000 && !defined(LIBRESSL_VERSION_NUMBER) return ASN1_STRING_cmp(lhs.raw(), rhs.raw()); #else return ASN1_STRING_cmp(const_cast(lhs.raw()), const_cast(rhs.raw())); diff --git a/libs/cryptoplus/include/cryptoplus/bio/bio_chain.hpp b/libs/cryptoplus/include/cryptoplus/bio/bio_chain.hpp index 35e2c398..88451b5b 100644 --- a/libs/cryptoplus/include/cryptoplus/bio/bio_chain.hpp +++ b/libs/cryptoplus/include/cryptoplus/bio/bio_chain.hpp @@ -99,10 +99,10 @@ namespace cryptoplus boost::shared_ptr m_bio; }; -#if OPENSSL_VERSION_NUMBER < 0x10100000L - inline bio_chain::bio_chain(BIO_METHOD* _type) : m_bio(BIO_new(_type), BIO_free_all) -#else +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) inline bio_chain::bio_chain(const BIO_METHOD* _type) : m_bio(BIO_new(_type), BIO_free_all) +#else + inline bio_chain::bio_chain(BIO_METHOD* _type) : m_bio(BIO_new(_type), BIO_free_all) #endif { throw_error_if_not(m_bio != NULL); diff --git a/libs/cryptoplus/include/cryptoplus/bio/bio_ptr.hpp b/libs/cryptoplus/include/cryptoplus/bio/bio_ptr.hpp index f41ec454..ddf28e02 100644 --- a/libs/cryptoplus/include/cryptoplus/bio/bio_ptr.hpp +++ b/libs/cryptoplus/include/cryptoplus/bio/bio_ptr.hpp @@ -501,7 +501,7 @@ namespace cryptoplus { return m_bio; } -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) inline bool bio_ptr::set_method(BIO_METHOD* _type) const { return BIO_set(m_bio, _type) != 0; diff --git a/libs/cryptoplus/include/cryptoplus/cryptoplus.hpp b/libs/cryptoplus/include/cryptoplus/cryptoplus.hpp index b03854ff..6281823b 100644 --- a/libs/cryptoplus/include/cryptoplus/cryptoplus.hpp +++ b/libs/cryptoplus/include/cryptoplus/cryptoplus.hpp @@ -74,7 +74,7 @@ namespace cryptoplus * * Only one instance of this class should be created. When an instance exists, the library can proceed to name resolutions. */ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) typedef initializer<_OpenSSL_add_all_algorithms, _null_function> algorithms_initializer; #else typedef initializer<_OpenSSL_add_all_algorithms, EVP_cleanup> algorithms_initializer; @@ -85,7 +85,7 @@ namespace cryptoplus * * Only one instance of this class should be created. When an instance exists, it will prevent memory leaks related to the libcrypto's internals. */ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) typedef initializer<_null_function, _null_function> crypto_initializer; #else typedef initializer<_null_function, CRYPTO_cleanup_all_ex_data> crypto_initializer; diff --git a/libs/cryptoplus/include/cryptoplus/error/error_strings.hpp b/libs/cryptoplus/include/cryptoplus/error/error_strings.hpp index 90b5d970..3f18b069 100644 --- a/libs/cryptoplus/include/cryptoplus/error/error_strings.hpp +++ b/libs/cryptoplus/include/cryptoplus/error/error_strings.hpp @@ -60,7 +60,7 @@ namespace cryptoplus * Only one instance of this class should be created. When an instance exists, the library can provide more informative error strings. */ -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) inline void _null_function() { } diff --git a/libs/cryptoplus/include/cryptoplus/hash/hmac_context.hpp b/libs/cryptoplus/include/cryptoplus/hash/hmac_context.hpp index 8bd3afd9..b0fcd081 100644 --- a/libs/cryptoplus/include/cryptoplus/hash/hmac_context.hpp +++ b/libs/cryptoplus/include/cryptoplus/hash/hmac_context.hpp @@ -144,7 +144,7 @@ namespace cryptoplus inline hmac_context::hmac_context() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) m_ctx = new HMAC_CTX; HMAC_CTX_init(m_ctx); #else @@ -154,7 +154,7 @@ namespace cryptoplus inline hmac_context::~hmac_context() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) HMAC_CTX_cleanup(m_ctx); delete m_ctx; #else @@ -192,7 +192,7 @@ namespace cryptoplus inline message_digest_algorithm hmac_context::algorithm() const { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) //WARNING: Here we directly use the undocumented HMAC_CTX.md field. return message_digest_algorithm(m_ctx->md); #else diff --git a/libs/cryptoplus/include/cryptoplus/hash/message_digest_context.hpp b/libs/cryptoplus/include/cryptoplus/hash/message_digest_context.hpp index 08a33d87..ee2f1fdd 100644 --- a/libs/cryptoplus/include/cryptoplus/hash/message_digest_context.hpp +++ b/libs/cryptoplus/include/cryptoplus/hash/message_digest_context.hpp @@ -73,7 +73,7 @@ namespace cryptoplus */ message_digest_context() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) m_ctx = new EVP_MD_CTX; EVP_MD_CTX_init(m_ctx); #else @@ -97,7 +97,7 @@ namespace cryptoplus */ ~message_digest_context() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX_cleanup(m_ctx); delete m_ctx; #else diff --git a/libs/cryptoplus/include/cryptoplus/pkey/dh_key.hpp b/libs/cryptoplus/include/cryptoplus/pkey/dh_key.hpp index 7d791082..c24d4f24 100644 --- a/libs/cryptoplus/include/cryptoplus/pkey/dh_key.hpp +++ b/libs/cryptoplus/include/cryptoplus/pkey/dh_key.hpp @@ -280,7 +280,7 @@ namespace cryptoplus { throw_error_if_not(PEM_write_DHparams(_file.raw(), ptr().get()) != 0); } -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) inline bn::bignum dh_key::private_key() const { const BIGNUM* priv_key = NULL; diff --git a/libs/cryptoplus/include/cryptoplus/pkey/pkey.hpp b/libs/cryptoplus/include/cryptoplus/pkey/pkey.hpp index db824a7d..354bacf2 100644 --- a/libs/cryptoplus/include/cryptoplus/pkey/pkey.hpp +++ b/libs/cryptoplus/include/cryptoplus/pkey/pkey.hpp @@ -565,7 +565,7 @@ namespace cryptoplus { return EVP_PKEY_size(ptr().get()); } -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) inline int pkey::type() const { return EVP_PKEY_base_id(ptr().get()); diff --git a/libs/cryptoplus/include/cryptoplus/random/random.hpp b/libs/cryptoplus/include/cryptoplus/random/random.hpp index 116b0f21..d8a0cfbd 100644 --- a/libs/cryptoplus/include/cryptoplus/random/random.hpp +++ b/libs/cryptoplus/include/cryptoplus/random/random.hpp @@ -227,7 +227,7 @@ namespace cryptoplus inline bool get_pseudo_random_bytes(void* buf, size_t buf_len) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) int result = RAND_pseudo_bytes(static_cast(buf), static_cast(buf_len)); throw_error_if(result < 0); @@ -242,7 +242,7 @@ namespace cryptoplus inline buffer get_pseudo_random_bytes(size_t cnt) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) buffer result(cnt); get_pseudo_random_bytes(buffer_cast(result), buffer_size(result)); diff --git a/libs/cryptoplus/src/dh_key.cpp b/libs/cryptoplus/src/dh_key.cpp index 981e8efc..b45808dc 100644 --- a/libs/cryptoplus/src/dh_key.cpp +++ b/libs/cryptoplus/src/dh_key.cpp @@ -65,7 +65,7 @@ namespace cryptoplus dh_key dh_key::generate_parameters(int prime_len, int generator, generate_callback_type callback, void* callback_arg) { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) static_cast(callback); static_cast(callback_arg); diff --git a/libs/cryptoplus/src/dsa_key.cpp b/libs/cryptoplus/src/dsa_key.cpp index 1794ca82..b48f7e39 100644 --- a/libs/cryptoplus/src/dsa_key.cpp +++ b/libs/cryptoplus/src/dsa_key.cpp @@ -65,7 +65,7 @@ namespace cryptoplus dsa_key dsa_key::generate_parameters(int bits, void* seed, size_t seed_len, int* counter_ret, unsigned long *h_ret, generate_callback_type callback, void* callback_arg, bool must_take_ownership) { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) static_cast(callback); static_cast(callback_arg); static_cast(must_take_ownership);