ZerBea / hcxtools

A small set of tools to convert packets from capture files to hash files for use with Hashcat or John the Ripper.
MIT License
2.03k stars 393 forks source link

implicit declaration of function ‘EVP_MAC_init’ #275

Closed goliath29 closed 1 year ago

goliath29 commented 1 year ago

When running 'Make' I am unable to proceed, with the install returning the below error message. I have installed all dependencies, but am unable to proceed further

`hcxpcapngtool.c:86:8: error: unknown type name ‘EVP_MAC’ static EVP_MAC hmac; ^~~ hcxpcapngtool.c:87:8: error: unknown type name ‘EVP_MAC’ static EVP_MAC cmac; ^~~ hcxpcapngtool.c:88:8: error: unknown type name ‘EVP_MAC_CTX’ static EVP_MAC_CTX ctxhmac; ^~~ hcxpcapngtool.c:89:8: error: unknown type name ‘EVP_MAC_CTX’ static EVP_MAC_CTX ctxcmac; ^~~ hcxpcapngtool.c:90:8: error: unknown type name ‘OSSL_PARAM’ static OSSL_PARAM paramsmd5[3]; ^~~~~~ hcxpcapngtool.c:91:8: error: unknown type name ‘OSSL_PARAM’ static OSSL_PARAM paramssha1[3]; ^~~~~~ hcxpcapngtool.c:92:8: error: unknown type name ‘OSSL_PARAM’ static OSSL_PARAM paramssha256[3]; ^~~~~~ hcxpcapngtool.c:93:8: error: unknown type name ‘OSSL_PARAM’ static OSSL_PARAM paramsaes128[3]; ^~~~~~ hcxpcapngtool.c: In function ‘testpmkid’: hcxpcapngtool.c:1953:5: warning: implicit declaration of function ‘EVP_MAC_init’; did you mean ‘EVP_MD_nid’? [-Wimplicit-function-declaration] if(!EVP_MAC_init(ctxhmac, testpmk, 32, paramssha1)) return false; ^~~~ EVP_MD_nid hcxpcapngtool.c:1954:5: warning: implicit declaration of function ‘EVP_MAC_update’; did you mean ‘HMAC_Update’? [-Wimplicit-function-declaration] if(!EVP_MAC_update(ctxhmac, pmkidcalc, 20)) return false; ^~~~~~ HMAC_Update hcxpcapngtool.c:1955:5: warning: implicit declaration of function ‘EVP_MAC_final’; did you mean ‘HMAC_Final’? [-Wimplicit-function-declaration] if(!EVP_MAC_final(ctxhmac, pmkidcalc, NULL, 20)) return false; ^~~~~ HMAC_Final hcxpcapngtool.c: In function ‘evpdeinitwpa’: hcxpcapngtool.c:5668:2: warning: implicit declaration of function ‘EVP_MAC_CTX_free’; did you mean ‘EVP_MD_CTX_free’? [-Wimplicit-function-declaration] EVP_MAC_CTX_free(ctxhmac); ^~~~ EVP_MD_CTX_free hcxpcapngtool.c:5669:2: warning: implicit declaration of function ‘EVP_MAC_free’; did you mean ‘EVP_PKEY_free’? [-Wimplicit-function-declaration] EVP_MAC_free(hmac); ^~~~ EVP_PKEY_free hcxpcapngtool.c: In function ‘evpinitwpa’: hcxpcapngtool.c:5700:8: warning: implicit declaration of function ‘EVP_MAC_fetch’; did you mean ‘EVP_PBE_get’? [-Wimplicit-function-declaration] hmac = EVP_MAC_fetch(NULL, "hmac", NULL); ^~~~~ EVP_PBE_get hcxpcapngtool.c:5700:6: warning: assignment to ‘int ’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] hmac = EVP_MAC_fetch(NULL, "hmac", NULL); ^ hcxpcapngtool.c:5702:6: warning: assignment to ‘int ’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] cmac = EVP_MAC_fetch(NULL, "cmac", NULL); ^ hcxpcapngtool.c:5705:16: warning: implicit declaration of function ‘OSSL_PARAM_construct_utf8_string’ [-Wimplicit-function-declaration] paramsmd5[0] = OSSL_PARAM_construct_utf8_string("digest", "md5", 0); ^~~~~~~~ hcxpcapngtool.c:5706:16: warning: implicit declaration of function ‘OSSL_PARAM_construct_end’ [-Wimplicit-function-declaration] paramsmd5[1] = OSSL_PARAM_construct_end(); ^~~~~~~~ hcxpcapngtool.c:5717:11: warning: implicit declaration of function ‘EVP_MAC_CTX_new’; did you mean ‘EVP_MD_CTX_new’? [-Wimplicit-function-declaration] ctxhmac = EVP_MAC_CTX_new(hmac); ^~~~~~~ EVP_MD_CTX_new hcxpcapngtool.c:5717:9: warning: assignment to ‘int ’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] ctxhmac = EVP_MAC_CTX_new(hmac); ^ hcxpcapngtool.c:5719:9: warning: assignment to ‘int ’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] ctxcmac = EVP_MAC_CTX_new(cmac); ^

make: *** No rule to make target 'hcxpcapngtool', needed by 'build'. Stop. `

ZerBea commented 1 year ago

hcxtools moved to OpenSSL 3.0 since 10.03.2023.

changelog:

10.03.2023
==========
release v6.2.8
moved to EVP API 3.0 (from now on OpenSSL >= 3.0 is mandatory)

README.md (section Requirements): * libopenssl (>= 3.0) and openssl-dev installed

OpenSSL < v3.0 does not provide this new API https://www.openssl.org/docs/man3.0/man3/EVP_MAC.html and it is mandatory to upgrade to at least v3.0

You received the ERRORS and the WARNINGS, because the 3.0 header files are missing on your system.

More information is e.g. here: https://github.com/ZerBea/hcxtools/issues/228

ZerBea commented 1 year ago

If the development files are installed:

$ pacman -Q | grep ssl
openssl 3.0.8-1

hcxtools compile (-lssl) as expected:

$ make
mkdir -p .deps
cc -O3 -Wall -Wextra -std=gnu99    -MMD -MF .deps/hcxpcapngtool.d -o hcxpcapngtool hcxpcapngtool.c -lssl -lcrypto  -lz   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99    -MMD -MF .deps/hcxhashtool.d -o hcxhashtool hcxhashtool.c -lssl -lcrypto  -lcurl   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99   -MMD -MF .deps/hcxpsktool.d -o hcxpsktool hcxpsktool.c -lssl -lcrypto   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99   -MMD -MF .deps/hcxpmktool.d -o hcxpmktool hcxpmktool.c -lssl -lcrypto   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99   -MMD -MF .deps/hcxeiutool.d -o hcxeiutool hcxeiutool.c   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99   -MMD -MF .deps/hcxwltool.d -o hcxwltool hcxwltool.c   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99   -MMD -MF .deps/hcxhash2cap.d -o hcxhash2cap hcxhash2cap.c   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99    -MMD -MF .deps/wlancap2wpasec.d -o wlancap2wpasec wlancap2wpasec.c -lssl -lcrypto  -lcurl   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB
cc -O3 -Wall -Wextra -std=gnu99    -MMD -MF .deps/whoismac.d -o whoismac whoismac.c -lssl -lcrypto  -lcurl   -DVERSION_TAG=\"6.3.0-3-gd615cc2\" -DVERSION_YEAR=\"2023\" -DWANTZLIB

the same applies to install:

$ sudo make install
install -D -m 0755 hcxpcapngtool /usr/bin/hcxpcapngtool
install -D -m 0755 hcxhashtool /usr/bin/hcxhashtool
install -D -m 0755 hcxpsktool /usr/bin/hcxpsktool
install -D -m 0755 hcxpmktool /usr/bin/hcxpmktool
install -D -m 0755 hcxeiutool /usr/bin/hcxeiutool
install -D -m 0755 hcxwltool /usr/bin/hcxwltool
install -D -m 0755 hcxhash2cap /usr/bin/hcxhash2cap
install -D -m 0755 wlancap2wpasec /usr/bin/wlancap2wpasec
install -D -m 0755 whoismac /usr/bin/whoismac
goliath29 commented 1 year ago

I have removed Openssl and updated to Openssl 3.1.0, but am still unable to run the make command, displaying the same error as above.

ZerBea commented 1 year ago

Have you installed the OpenSSL includes, too. I ask this, because your compilers does not find them.

By default installation, they are placed here: /usr/include/openssl/

$ cd /usr/include/openssl/
$ grep -r EVP_MAC
types.h:typedef struct evp_mac_st EVP_MAC;
types.h:typedef struct evp_mac_ctx_st EVP_MAC_CTX;
evp.h:EVP_MAC *EVP_MAC_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
evp.h:int EVP_MAC_up_ref(EVP_MAC *mac);
evp.h:void EVP_MAC_free(EVP_MAC *mac);
evp.h:const char *EVP_MAC_get0_name(const EVP_MAC *mac);
evp.h:const char *EVP_MAC_get0_description(const EVP_MAC *mac);
evp.h:int EVP_MAC_is_a(const EVP_MAC *mac, const char *name);
evp.h:const OSSL_PROVIDER *EVP_MAC_get0_provider(const EVP_MAC *mac);
evp.h:int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]);
evp.h:EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac);
evp.h:void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx);
evp.h:EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src);
evp.h:EVP_MAC *EVP_MAC_CTX_get0_mac(EVP_MAC_CTX *ctx);
evp.h:int EVP_MAC_CTX_get_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[]);
evp.h:int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]);
evp.h:size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx);
evp.h:size_t EVP_MAC_CTX_get_block_size(EVP_MAC_CTX *ctx);
evp.h:int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen,
evp.h:int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen);
evp.h:int EVP_MAC_final(EVP_MAC_CTX *ctx,
evp.h:int EVP_MAC_finalXOF(EVP_MAC_CTX *ctx, unsigned char *out, size_t outsize);
evp.h:const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac);
evp.h:const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac);
evp.h:const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac);
evp.h:const OSSL_PARAM *EVP_MAC_CTX_gettable_params(EVP_MAC_CTX *ctx);
evp.h:const OSSL_PARAM *EVP_MAC_CTX_settable_params(EVP_MAC_CTX *ctx);
evp.h:void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx,
evp.h:                             void (*fn)(EVP_MAC *mac, void *arg),
evp.h:int EVP_MAC_names_do_all(const EVP_MAC *mac,
tls1.h:                             EVP_CIPHER_CTX *, EVP_MAC_CTX *, int));

And they are missing on versions < 3.x:

$ cd /usr/include/openssl-1.0/openssl/
$ grep -r EVP_MAC
$ 
ZerBea commented 1 year ago

While evp.h is present on all OpenSSL versions.

$ locate evp.h
/usr/include/openssl/evp.h
/usr/include/openssl-1.0/openssl/evp.h
/usr/include/xmlsec1/xmlsec/openssl/evp.h

The new EVP API is only present on > 3.0 /usr/include/openssl/evp.h

older versions do not provide this API: /usr/include/openssl-1.0/openssl/evp.h

goliath29 commented 1 year ago

I have since reinstalled libssl, openssl and hcxtools again to no success.

I do have the evp.h as mentioned above, but the error still persists.

ZerBea commented 1 year ago

How have you installed openssl? Via package manager of your Linux distribution? In that case your distribution should know where to find the includes. or From source? In that case, your Linux distribution does not know about the includes and you have to set path by hand. How to do this, depend on your Linux distribution.

ZerBea commented 1 year ago

This will show the active version:

$ openssl version
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)
ZerBea commented 1 year ago

This will show gcc default include path:

$ `gcc -print-prog-name=cc1` -v
 /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/include-fixed
 /usr/include
ZerBea commented 1 year ago

This will cd into the default openssl path: $ cd /usr/include/openssl

this will list the EVP API:

$ grep -R EVP_MAC
types.h:typedef struct evp_mac_st EVP_MAC;
types.h:typedef struct evp_mac_ctx_st EVP_MAC_CTX;
...
ZerBea commented 1 year ago

That should be the default on all Linux distributions.

ZerBea commented 1 year ago

It looks the other conditions apply

* zlib and zlib-dev installed (for gzip compressed cap/pcap/pcapng files)
* libcurl (>= 7.56) and curl-dev installed (used by whoismac and wlancap2wpasec)
* pkg-config installed

and pkg-config find them. Is openssl.pc present in pkg-config dir and point it to the correct path?

$ cat /usr/lib/pkgconfig/openssl.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: OpenSSL
Description: Secure Sockets Layer and cryptography libraries and tools
Version: 3.0.8
Requires: libssl libcrypto

BTW: Which gcc version do you use?

The other conditions

ZerBea commented 1 year ago

Closed due to missing dependency.