blackbird icon indicating copy to clipboard operation
blackbird copied to clipboard

HMAC_CTX ctx has incomplete type

Open lovesegfault opened this issue 7 years ago • 28 comments

While attempting to build on Arch Linux I get the following compilation error

In file included from /home/bemeurer/src/blackbird/src/exchanges/exmo.cpp:7:0:
/home/bemeurer/src/blackbird/src/utils/hmac_sha512.hpp: In constructor ‘HMAC_SHA512::HMAC_SHA512(const string&, const string&)’:
/home/bemeurer/src/blackbird/src/utils/hmac_sha512.hpp:11:12: error: aggregate ‘HMAC_CTX ctx’ has incomplete type and cannot be defined
   HMAC_CTX ctx;
            ^~~
/home/bemeurer/src/blackbird/src/utils/hmac_sha512.hpp:12:3: error: ‘HMAC_CTX_init’ was not declared in this scope
   HMAC_CTX_init(&ctx);
   ^~~~~~~~~~~~~
/home/bemeurer/src/blackbird/src/utils/hmac_sha512.hpp:12:3: note: suggested alternative: ‘HMAC_CTX_new’
   HMAC_CTX_init(&ctx);
   ^~~~~~~~~~~~~
   HMAC_CTX_new
/home/bemeurer/src/blackbird/src/utils/hmac_sha512.hpp:27:3: error: ‘HMAC_CTX_cleanup’ was not declared in this scope
   HMAC_CTX_cleanup(&ctx);
   ^~~~~~~~~~~~~~~~
/home/bemeurer/src/blackbird/src/utils/hmac_sha512.hpp:27:3: note: suggested alternative: ‘HMAC_CTX_get_md’
   HMAC_CTX_cleanup(&ctx);
   ^~~~~~~~~~~~~~~~
   HMAC_CTX_get_md
make[2]: *** [CMakeFiles/blackbird.dir/build.make:361: CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/blackbird.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

lovesegfault avatar Dec 24 '17 01:12 lovesegfault

-DOPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0 -DOPENSSL_SSL_LIBRARY=/usr/lib/openssl-1.0/libssl.so -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/openssl-1.0/libcrypto.so Put this extra params after you cmake command

hnws avatar Dec 24 '17 04:12 hnws

That did fix it, thank you!

lovesegfault avatar Dec 24 '17 19:12 lovesegfault

@hnws i am getting the same on debian 9.3. cmake does find the local ssl libs but i am already on 1.1.0f and getting the same error like @bemeurer. any ideas? i tried link them manually like you explained but actually i dont have them in the same location so i had to modify the command. thais also did not helt :)

itskeKs avatar Jan 03 '18 21:01 itskeKs

-DOPENSSL_INCLUDE_DIR=/usr/include/openssl -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0

for debian 9.x and may be install libssl1.0-dev

Alexandre-io avatar Jan 04 '18 10:01 Alexandre-io

@Alexandre-io thanks the install of the package did the trick.

itskeKs avatar Jan 06 '18 18:01 itskeKs

I am having the same or similar issue on Windows: Slightly different, instead of using command line -D definitions I declared it in CMakeLists.txt:

set (OPENSSL_ROOT_DIR "/lib/openssl-1.1.0g") set (OPENSSL_CRYPTO_LIBRARY "/lib/openssl-1.1.0g/lib") set (OPENSSL_SSL_LIBRARY "/lib/openssl-1.1.0g/lib") set (OPENSSL_INCLUDE_DIR "/lib/openssl-1.1.0g/include")

I use Visual Studio 2017 Community version. CMake Build seems without any error, but with warnings:

-- The C compiler identification is MSVC 19.12.25831.0 -- The CXX compiler identification is MSVC 19.12.25831.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx86/x64/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx86/x64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx86/x64/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/bin/Hostx86/x64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- cotire 1.7.9 loaded. -- Found CURL: C:/lib/curl/lib/libcurl.lib -- Found Jansson: /lib/jansson-2.10/lib -- Found OpenSSL: /lib/openssl-1.1.0g/lib/libcrypto.lib (found version "1.1.0g") -- Found SQLITE3: /lib/sqlite3/ -- CXX target blackbird cotired. -- Configuring done WARNING: Target "blackbird" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/jansson-2.10/lib". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "blackbird_unity" requests linking to directory "/lib/sqlite3/". Targets may link only to libraries. CMake is dropping the item. -- Generating done -- Build files have been written to: C:/blackbird/build

However when I compile it from Visual Studio I get:

Severity Code Description Project File Line Suppression State Error C2079 'ctx' uses undefined struct 'hmac_ctx_st' blackbird C:\DEV\BitcoinArbitrage\blackbird\src\utils\hmac_sha512.hpp 11 Error C3861 'HMAC_CTX_init': identifier not found blackbird C:\DEV\BitcoinArbitrage\blackbird\src\utils\hmac_sha512.hpp 12 Error C2664 'int HMAC_Init_ex(HMAC_CTX *,const void *,int,const EVP_MD *,ENGINE *)': cannot convert argument 1 from 'int *' to 'HMAC_CTX *' blackbird C:\DEV\BitcoinArbitrage\blackbird\src\utils\hmac_sha512.hpp 15 Error C2664 'int HMAC_Update(HMAC_CTX *,const unsigned char *,::size_t)': cannot convert argument 1 from 'int *' to 'HMAC_CTX *' blackbird C:\DEV\BitcoinArbitrage\blackbird\src\utils\hmac_sha512.hpp 18 Error C2664 'int HMAC_Final(HMAC_CTX *,unsigned char *,unsigned int *)': cannot convert argument 1 from 'int *' to 'HMAC_CTX *' blackbird C:\DEV\BitcoinArbitrage\blackbird\src\utils\hmac_sha512.hpp 23 Error C3861 'HMAC_CTX_cleanup': identifier not found blackbird C:\DEV\BitcoinArbitrage\blackbird\src\utils\hmac_sha512.hpp 27

looking at the hmac.h include file it is indeed missing 'HMAC_CTX_init', 'int HMAC_Init_ex and the rest ... Here is what I got for hmac.h:

/*

  • Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  • Licensed under the OpenSSL license (the "License"). You may not use
  • this file except in compliance with the License. You can obtain a copy
  • in the file LICENSE in the source distribution or at
  • https://www.openssl.org/source/license.html */

#ifndef HEADER_HMAC_H

define HEADER_HMAC_H

include <openssl/opensslconf.h>

include <openssl/evp.h>

define HMAC_MAX_MD_CBLOCK 128/* largest known is SHA512 */

#ifdef __cplusplus extern "C" { #endif

size_t HMAC_size(const HMAC_CTX *e); HMAC_CTX *HMAC_CTX_new(void); int HMAC_CTX_reset(HMAC_CTX *ctx); void HMAC_CTX_free(HMAC_CTX *ctx);

DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md))

/__owur/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD md, ENGINE impl); /__owur/ int HMAC_Update(HMAC_CTX ctx, const unsigned char data, size_t len); /__owur/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len); __owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);

void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx);

#ifdef __cplusplus } #endif

#endif

How do I fix all of these?

Thanks in advance, Aharon

at1087 avatar Jan 07 '18 19:01 at1087

@at1087 I am reopening this issue, but unless you format that text properly I will close it again. You can use triple backticks ``` to denote code.

lovesegfault avatar Jan 07 '18 19:01 lovesegfault

Will do @bemeurer ... and thanks

at1087 avatar Jan 14 '18 04:01 at1087

Same issue building on Ubuntu 16.04 LTS with libssl1.0-dev already installed

emcxh35 avatar Jan 15 '18 10:01 emcxh35

Using the command cmake -B./build -H. -DCMAKE_BUILD_TYPE=Release -DOPENSSL_INCLUDE_DIR=/usr/include/openssl -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2

followed by cmake --build ./build -- install

results in the following errors [ 3%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o In file included from /home/vagrant/blackbird/src/exchanges/exmo.cpp:7:0: /home/vagrant/blackbird/src/utils/hmac_sha512.hpp: In constructor ‘HMAC_SHA512::HMAC_SHA512(const string&, const string&)’: /home/vagrant/blackbird/src/utils/hmac_sha512.hpp:11:12: error: aggregate ‘HMAC_CTX ctx’ has incomplete type and cannot be defined HMAC_CTX ctx; ^ /home/vagrant/blackbird/src/utils/hmac_sha512.hpp:12:21: error: ‘HMAC_CTX_init’ was not declared in this scope HMAC_CTX_init(&ctx); ^ /home/vagrant/blackbird/src/utils/hmac_sha512.hpp:27:24: error: ‘HMAC_CTX_cleanup’ was not declared in this scope HMAC_CTX_cleanup(&ctx); ^ CMakeFiles/blackbird.dir/build.make:435: recipe for target 'CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o' failed

emcxh35 avatar Jan 15 '18 11:01 emcxh35

Hi all,

I ran three different commands, as I found three different files for DOPENSSL_SSL_LIBRARY and DOPENSSL_CRYPTO_LIBRARY in my system

# cmake -DOPENSSL_INCLUDE_DIR=/usr/include/ssl -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so.1.1 -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 -B./build -H. -DCMAKE_BUILD_TYPE=Release
#  cmake --build ./build -- install

# cmake -DOPENSSL_INCLUDE_DIR=/usr/include/ssl -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 -B./build -H. -DCMAKE_BUILD_TYPE=Release
#  cmake --build ./build -- install

# cmake -DOPENSSL_INCLUDE_DIR=/usr/include/ssl -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so -B./build -H. -DCMAKE_BUILD_TYPE=Release
#  cmake --build ./build -- install

Each time i received the same output for the build command:

#  cmake --build ./build -- install
[  3%] Generating CXX unity source cotire/blackbird_CXX_unity.cxx
[  7%] Generating CXX prefix source cotire/blackbird_CXX_prefix.cxx
[ 10%] Generating CXX prefix header cotire/blackbird_CXX_prefix.hxx
[ 14%] Building CXX precompiled header cotire/blackbird_CXX_prefix.hxx.gch
Scanning dependencies of target blackbird
[ 17%] Building CXX object CMakeFiles/blackbird.dir/src/bitcoin.cpp.o
[ 21%] Building CXX object CMakeFiles/blackbird.dir/src/check_entry_exit.cpp.o
[ 25%] Building CXX object CMakeFiles/blackbird.dir/src/curl_fun.cpp.o
[ 28%] Building CXX object CMakeFiles/blackbird.dir/src/db_fun.cpp.o
[ 32%] Building CXX object CMakeFiles/blackbird.dir/src/main.cpp.o
[ 35%] Building CXX object CMakeFiles/blackbird.dir/src/parameters.cpp.o
[ 39%] Building CXX object CMakeFiles/blackbird.dir/src/result.cpp.o
[ 42%] Building CXX object CMakeFiles/blackbird.dir/src/time_fun.cpp.o
[ 46%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/bitfinex.cpp.o
[ 50%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/bitstamp.cpp.o
[ 53%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/btce.cpp.o
[ 57%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/cexio.cpp.o
/opt/blackbird/src/exchanges/cexio.cpp: In function ‘double Cexio::getAvail(Parameters&, std::__cxx11::string)’:
/opt/blackbird/src/exchanges/cexio.cpp:56:15: warning: unused variable ‘returnedText’ [-Wunused-variable]
   const char* returnedText = NULL;
               ^~~~~~~~~~~~
[ 60%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o
In file included from /opt/blackbird/src/exchanges/exmo.cpp:7:0:
/opt/blackbird/src/utils/hmac_sha512.hpp: In constructor ‘HMAC_SHA512::HMAC_SHA512(const string&, const string&)’:
/opt/blackbird/src/utils/hmac_sha512.hpp:11:12: error: aggregate ‘HMAC_CTX ctx’ has incomplete type and cannot be defined
   HMAC_CTX ctx;
            ^~~
/opt/blackbird/src/utils/hmac_sha512.hpp:12:3: error: ‘HMAC_CTX_init’ was not declared in this scope
   HMAC_CTX_init(&ctx);
   ^~~~~~~~~~~~~
/opt/blackbird/src/utils/hmac_sha512.hpp:12:3: note: suggested alternative: ‘HMAC_CTX_new’
   HMAC_CTX_init(&ctx);
   ^~~~~~~~~~~~~
   HMAC_CTX_new
/opt/blackbird/src/utils/hmac_sha512.hpp:27:3: error: ‘HMAC_CTX_cleanup’ was not declared in this scope
   HMAC_CTX_cleanup(&ctx);
   ^~~~~~~~~~~~~~~~
/opt/blackbird/src/utils/hmac_sha512.hpp:27:3: note: suggested alternative: ‘HMAC_CTX_get_md’
   HMAC_CTX_cleanup(&ctx);
   ^~~~~~~~~~~~~~~~
   HMAC_CTX_get_md
CMakeFiles/blackbird.dir/build.make:385: recipe for target 'CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o' failed
make[2]: *** [CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/blackbird.dir/all' failed
make[1]: *** [CMakeFiles/blackbird.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Here's how my environment looks like

# uname -a
Linux kalihost 4.14.0-kali3-amd64 #1 SMP Debian 4.14.13-1kali1 (2018-01-25) x86_64 GNU/Linux

# cat /etc/*-release
DISTRIB_ID=Kali
DISTRIB_RELEASE=kali-rolling
DISTRIB_CODENAME=kali-rolling
DISTRIB_DESCRIPTION="Kali GNU/Linux Rolling"
PRETTY_NAME="Kali GNU/Linux Rolling"
NAME="Kali GNU/Linux"
ID=kali
VERSION="2018.1"
VERSION_ID="2018.1"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.kali.org/"
SUPPORT_URL="http://forums.kali.org/"
BUG_REPORT_URL="http://bugs.kali.org/"

jack5432109 avatar Feb 06 '18 17:02 jack5432109

Have the same problem with Ubuntu in AWS, tried to use

# cmake -DOPENSSL_INCLUDE_DIR=/usr/include/ssl -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so -B./build -H. -DCMAKE_BUILD_TYPE=Release
#  cmake --build ./build -- install

Nothing works

deios0 avatar Feb 11 '18 19:02 deios0

Is this software even maintained?

lovesegfault avatar Feb 11 '18 21:02 lovesegfault

Installing compat-openssl10-devel solved the issue on Fedora 27.

galileo-pkm avatar Feb 28 '18 00:02 galileo-pkm

If you encountered this compiling issue - "aggregate ‘HMAC_CTX ctx’ has incomplete type and cannot be defined" etc, basically, it means you're using a higher version of openssl (>=v1.1.0). So, you have two options: one is using a lower version, the other is upgrading the source code for your platform. For upgrading, please read this blog: https://developer.akamai.com/blog/2017/02/14/upgrade-openssl-1-1-0/ I'm not sure whether a patch is available already.

douyw avatar Mar 24 '18 13:03 douyw

I use linux mint 17.1 (based on ubuntu so usefull for it too). I have no libssl1.0-dev in repo. But have libssl-dev which version is 1.1.0 by default. Synaptic packet manager allow to change libssl-dev version to 1.0.1. (select the packet, click "packet" in upper toolbar, click change version). It also can be done via console.

So I just change version of this packet then check that libssl1.0.0 installed then use cmake -B./build -H. -DCMAKE_BUILD_TYPE=Release -DOPENSSL_INCLUDE_DIR=/usr/include/openssl -DOPENSSL_SSL_LIBRARY=/lib/x86_64-linux-gnu/libssl.so.1.0.0 -DOPENSSL_CRYPTO_LIBRARY=/lib/x86_64-linux-gnu/libcrypto.so.1.0.0

and it works.

pay attention: path to libraries can differ (/lib/x86_64-linux-gnu/...). you can check it in packet info.

am-unklown avatar May 13 '18 19:05 am-unklown

@DDoSed in ubuntu 18.04 it doens't work because version 1.1.0 is the only available version, but I think it works in older ubuntus versions

ielson avatar May 13 '18 20:05 ielson

Working code of hmac_sha512.hpp for ubuntu 18.04 with openssl 1.1.0 is

#ifndef HMAC_SHA512_HPP
#define HMAC_SHA512_HPP

#include <openssl/hmac.h>
#include <string>
#include <vector>

class HMAC_SHA512 {
public:
	HMAC_SHA512(const std::string& key, const std::string& msg) {
		HMAC_CTX *ctx = HMAC_CTX_new();
		//HMAC_CTX_init(&ctx);

		// Set HMAC key.
		HMAC_Init_ex(ctx, reinterpret_cast<const unsigned char*>(key.c_str()), key.size(), EVP_sha512(), NULL);

		// May be called repeatedly to insert all your data.
		HMAC_Update(ctx, reinterpret_cast<const unsigned char*>(msg.c_str()), msg.size());

		// Finish HMAC computation and fetch result.
		unsigned char* result = new unsigned char[129];
		unsigned int result_len = 129;
		HMAC_Final(ctx, result, &result_len);
		for (unsigned int i = 0; i < result_len; i++) {
			digest_.push_back(int(result[i]));
		}
		HMAC_CTX_free(ctx);
	}

	std::string hex_digest() {
		std::string str;
		const char hex_chars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
		for (auto i : digest_) {
			const char byte = i;
			str.push_back(hex_chars[(byte & 0xF0) >> 4]);
			str.push_back(hex_chars[(byte & 0x0F) >> 0]);
		}
		return str;
	}

private:
	std::vector<unsigned char> digest_;
};

#endif // HMAC_SHA512_HPP

Custler avatar May 29 '18 05:05 Custler

I also got this issue, anybody solved it yet

jackynguyen93 avatar May 31 '18 10:05 jackynguyen93

I today download the latest version of a blackbird and during installation, I have gotten the same error.

[ 60%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o In file included from /home/ytigiev/blackbird/blackbird/src/exchanges/exmo.cpp:7:0: /home/ytigiev/blackbird/blackbird/src/utils/hmac_sha512.hpp: In constructor ‘HMAC_SHA512::HMAC_SHA512(const string&, const string&)’: /home/ytigiev/blackbird/blackbird/src/utils/hmac_sha512.hpp:11:12: error: aggregate ‘HMAC_CTX ctx’ has incomplete type and cannot be defined HMAC_CTX ctx;

How can fix the issue? Who can share instructions? I have used all suggests from the current posts.

cat /etc/os-release NAME="Ubuntu" VERSION="18.04.1 LTS (Bionic Beaver)"

YuriyTigiev avatar Jan 06 '19 20:01 YuriyTigiev

To fix this, the blackbird code needs to be updated to use the modified APIs in OpenSSL 1.1. For example instead of creating a HMAC_CTX directly (as an automatic variable), you must now call HMAC_CTX_new(). See https://developer.akamai.com/blog/2017/02/14/upgrade-openssl-110

jzwinck avatar Jan 28 '19 03:01 jzwinck

As a work-around if you don't use exmo, you can simply remove the 2 lines from

std::string getSignature(Parameters& params, std::string msg)

in exmo.cpp and just return NULL.

sebthauvette avatar Feb 21 '19 18:02 sebthauvette

Sorry but new to C (not my programming language of choice), can you point at the location of the file to be open after the standard installation as from github guide, and tell wich lines need to be commented or deleted? (I can open it and modify the file with nano or vi , right??than just save it in the same location..)

or just point at the new complete source code to be overwritten in that location? thanks!

bodytexture avatar Apr 13 '20 02:04 bodytexture

UPDATE: I have made it to change the hmac_sha512.hpp file as from the example above.. (if I've didnt go wrong with the sintax) ,now I get this error after i run: cmake --build ./build -- install

make[2]: *** No rule to make target '/usr/lib/openssl-1.0/libssl.so', needed by 'blackbird'. Stop. CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/blackbird.dir/all' failed make[1]: *** [CMakeFiles/blackbird.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

bodytexture avatar Apr 13 '20 03:04 bodytexture

SECOND UPDATE: tried also with the workaround (as I'm not using exmo) and after modifyng the exmo.cpp, i got this:

cmake --build ./build -- install

Scanning dependencies of target blackbird [ 3%] Building CXX object CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o In file included from /home/ubuntu/blackbird/src/exchanges/exmo.cpp:8:0: /home/ubuntu/blackbird/src/utils/hmac_sha512.hpp: In constructor ‘HMAC_SHA512::HMAC_SHA512(const string&, const string&)’: /home/ubuntu/blackbird/src/utils/hmac_sha512.hpp:11:12: error: aggregate ‘HMAC_CTX ctx’ has incomplete type and cannot be defined HMAC_CTX ctx; ^~~ /home/ubuntu/blackbird/src/utils/hmac_sha512.hpp:12:3: error: ‘HMAC_CTX_init’ was not declared in this scope HMAC_CTX_init(&ctx); ^~~~~~~~~~~~~ /home/ubuntu/blackbird/src/utils/hmac_sha512.hpp:12:3: note: suggested alternative: ‘HMAC_CTX_new’ HMAC_CTX_init(&ctx); ^~~~~~~~~~~~~ HMAC_CTX_new /home/ubuntu/blackbird/src/utils/hmac_sha512.hpp:27:3: error: ‘HMAC_CTX_cleanup’ was not declared in this scope HMAC_CTX_cleanup(&ctx); ^~~~~~~~~~~~~~~~ /home/ubuntu/blackbird/src/utils/hmac_sha512.hpp:27:3: note: suggested alternative: ‘HMAC_CTX_get_md’ HMAC_CTX_cleanup(&ctx); ^~~~~~~~~~~~~~~~ HMAC_CTX_get_md CMakeFiles/blackbird.dir/build.make:410: recipe for target 'CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o' failed make[2]: *** [CMakeFiles/blackbird.dir/src/exchanges/exmo.cpp.o] Error 1 CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/blackbird.dir/all' failed make[1]: *** [CMakeFiles/blackbird.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

bodytexture avatar Apr 13 '20 04:04 bodytexture

on the first UPDATE VPS i have OpenSSL 1.1.1c 28 May 2019 on the SECOND UPDATE VPS i have OpenSSL 1.0.2j 26 Sep 2016

bodytexture avatar Apr 13 '20 04:04 bodytexture

Hi @bodytexture, I think I just solve the problem for me so maybe it could help you to see what I did.

First I modified hmac_sha512.hpp; (line 11 to 27) `HMAC_CTX *ctx = HMAC_CTX_new(); //HMAC_CTX_init(&ctx);

	// Set HMAC key.
	HMAC_Init_ex(ctx, reinterpret_cast<const unsigned char*>(key.c_str()), key.size(), EVP_sha512(), NULL);

	// May be called repeatedly to insert all your data.
	HMAC_Update(ctx, reinterpret_cast<const unsigned char*>(msg.c_str()), msg.size());

	// Finish HMAC computation and fetch result.
	unsigned char* result = new unsigned char[129];
	unsigned int result_len = 129;
	HMAC_Final(ctx, result, &result_len);
	for (unsigned int i = 0; i < result_len; i++) {
		digest_.push_back(int(result[i]));
	}
	HMAC_CTX_free(ctx);`

(I did this changes thanks to this link https://developer.akamai.com/blog/2017/02/14/upgrade-openssl-110)

Then I used the following command cmake -B./build -H. -DCMAKE_BUILD_TYPE=Release -DOPENSSL_INCLUDE_DIR=/usr/include/openssl-1.1 -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so You may need to find the libssl.so and libcrypto.so path, this command can helps too: sudo find / -iname "libssl.so"

Finally the build worked. Hope It can helps!

Ps: Excuse my English and the presentation of my message it's the first time I use the comment section. I'am a beginner too :)

clementjuventin avatar May 24 '20 11:05 clementjuventin

Hello Clementin,

many thanks for the reply, I solved the ssl problem by installing one of the latest forks, meanwhile.

I'm testing it now to have a grasp in "production" (demo mode = false) I get this error:

<Bitfinex> Error with response: Invalid X-BFX-SIGNATURE.

bitfinex checks ok for the quotes and the rest correctly but dose not show the usd ballance amount (i have a few dollars in the margin account correctly, but still shows 0.00...).

the othe leg is binance, there is no usd currency pair (as from your instructions) so i've deposited on usdt (is that ok?), but also there I see no founds on production at start (should i deposit on some other stablecoin to see ballance? why I see no founds?).

any solution to this problems in latest forks or someware else? wich fork are you using? maybe you can point me at a version of the software that dose not show this errors?

any more recent fork or other place to look for more advanced versions of the software that sopport a few more exchanges?

many thanks anyway!

carlo

Il giorno dom 24 mag 2020 alle ore 08:43 clementjuventin < [email protected]> ha scritto:

Hi @bodytexture https://github.com/bodytexture, I think I just solve the problem for me so maybe it could help you to see what I did.

First I modified hmac_sha512.hpp; (line 11 to 27) `HMAC_CTX *ctx = HMAC_CTX_new(); //HMAC_CTX_init(&ctx);

// Set HMAC key. HMAC_Init_ex(ctx, reinterpret_cast<const unsigned char*>(key.c_str()), key.size(), EVP_sha512(), NULL);

// May be called repeatedly to insert all your data. HMAC_Update(ctx, reinterpret_cast<const unsigned char*>(msg.c_str()), msg.size());

// Finish HMAC computation and fetch result. unsigned char* result = new unsigned char[129]; unsigned int result_len = 129; HMAC_Final(ctx, result, &result_len); for (unsigned int i = 0; i < result_len; i++) { digest_.push_back(int(result[i])); } HMAC_CTX_free(ctx);`

(I did this changes thanks to this link https://developer.akamai.com/blog/2017/02/14/upgrade-openssl-110)

Then I used the following command cmake -B./build -H. -DCMAKE_BUILD_TYPE=Release -DOPENSSL_INCLUDE_DIR=/usr/include/openssl-1.1 -DOPENSSL_SSL_LIBRARY=/usr/lib/x86_64-linux-gnu/libssl.so -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/x86_64-linux-gnu/libcrypto.so You may need to find the libssl.so and libcrypto.so path, this command can helps too: sudo find / -iname "libssl.so"

Finally the build worked. Hope It can helps!

Ps: Excuse my English and the presentation of my message it's the first time I use the comment section. I'am a beginner too :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/butor/blackbird/issues/353#issuecomment-633218619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEX6XDAKEEPP7PNIL4PZSN3RTEB73ANCNFSM4EJPHG7Q .

bodytexture avatar May 25 '20 14:05 bodytexture