Cemu icon indicating copy to clipboard operation
Cemu copied to clipboard

[Linux] build fails with "error: 'EC_POINT_get_affine_coordinates_GF2m' was not declared in this scope"

Open SupervisedThinking opened this issue 3 years ago • 5 comments

Probably an issue caused by OpenSSL 3.0.5? Since you've dealt with openssl related stuff before, might have a look @bitscher 🙈

The OpenSSL package used is build with no-ec2m flag: https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/security/openssl/package.mk#L19

But I could image currently it's expected to have elliptic curve support? https://wiki.openssl.org/index.php?title=Compilation_and_Installation&action=edit&section=11

Is this mandatory? Or is it more like https://www.openssl.org/docs/man1.1.1/man3/EC_POINT_get_affine_coordinates_GF2m.html describes:

The functions EC_POINT_get_affine_coordinates_GFp() and EC_POINT_get_affine_coordinates_GF2m() are synonyms for EC_POINT_get_affine_coordinates(). They are defined for backwards compatibility only and should not be used.

build log:

FAILED: src/Cafe/CMakeFiles/CemuCafe.dir/IOSU/legacy/iosu_crypto.cpp.o 
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ -DBOOST_NOWIDE_DYN_LINK -DBOOST_NOWIDE_NO_LIB -DHAS_CUBEB=1 -DPUBLIC_RELEASE -DVK_NO_PROTOTYPES -DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XLIB_KHR -DWXUSINGDLL -D_UNICODE -D__WXGTK3__ -D__WXGTK__ -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/.x86_64-libreelec-linux-gnu/src/Cafe -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/dependencies/Vulkan-Headers/include -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/audio/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/dependencies/cubeb/include -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/.x86_64-libreelec-linux-gnu/exports -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Common/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/dependencies/fmt/include -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cemu/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/config/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/gui/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/input/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/resource/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/util/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/imgui/.. -I/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/dependencies/ZArchive/include -isystem /build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/lib/wx/include/gtk3-unicode-3.2 -isystem /build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/wx-3.2 -march=x86-64-v2 -Wall -pipe  -O2 -fomit-frame-pointer -DNDEBUG -O3 -DNDEBUG -flto=auto -fno-fat-lto-objects   -fms-extensions -fpermissive -maes -Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion -mssse3 -mavx2 -std=gnu++20 -Winvalid-pch -include /build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/.x86_64-libreelec-linux-gnu/src/Cafe/CMakeFiles/CemuCafe.dir/cmake_pch.hxx -MD -MT src/Cafe/CMakeFiles/CemuCafe.dir/IOSU/legacy/iosu_crypto.cpp.o -MF src/Cafe/CMakeFiles/CemuCafe.dir/IOSU/legacy/iosu_crypto.cpp.o.d -o src/Cafe/CMakeFiles/CemuCafe.dir/IOSU/legacy/iosu_crypto.cpp.o -c /build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp: In function 'std::string iosuCrypto_base64Encode(const unsigned char*, unsigned int)':
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp:138:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |         cemu_assert_debug(outputLen < strB64.size());
      |                           ~~~~~~~~~~^~~~~~~~~~~~~~~
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp: In function 'EC_KEY* ECCPubKey_getPublicKey(ECCPubKey&)':
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp:151:53: warning: 'EC_KEY* EC_KEY_new_by_curve_name(int)' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
  151 |         EC_KEY* ec_pubKey = EC_KEY_new_by_curve_name(NID_sect233r1);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp:6:
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/openssl/ec.h:998:31: note: declared here
  998 | OSSL_DEPRECATEDIN_3_0 EC_KEY *EC_KEY_new_by_curve_name(int nid);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp:152:57: warning: 'int EC_KEY_set_public_key_affine_coordinates(EC_KEY*, BIGNUM*, BIGNUM*)' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
  152 |         int r = EC_KEY_set_public_key_affine_coordinates(ec_pubKey, bn_r, bn_s);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/openssl/ec.h:1122:27: note: declared here
 1122 | OSSL_DEPRECATEDIN_3_0 int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key,
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp:152:13: warning: unused variable 'r' [-Wunused-variable]
  152 |         int r = EC_KEY_set_public_key_affine_coordinates(ec_pubKey, bn_r, bn_s);
      |             ^
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp: In function 'void iosuCrypto_generateDeviceCertificate()':
/build/LibreELEC-RR/build.LibreELEC-x11.x86_64-11.0-devel/build/cemu-d23bbd7d9a6cc2aedbe29bbfca358f59f6b049cf/src/Cafe/IOSU/legacy/iosu_crypto.cpp:276:9: error: 'EC_POINT_get_affine_coordinates_GF2m' was not declared in this scope; did you mean 'EC_POINT_get_affine_coordinates_GFp'?
  276 |         EC_POINT_get_affine_coordinates_GF2m(group, pubkey, bn_x, bn_y, NULL);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         EC_POINT_get_affine_coordinates_GFp

SupervisedThinking avatar Aug 31 '22 14:08 SupervisedThinking

Could anyone with OpenSSL 1.1.1 check if this patch breaks his build/runtime? https://github.com/SupervisedThinking/Cemu/commit/191401369000f7300d58844c1fe5d1e971c2d2d0

SupervisedThinking avatar Sep 01 '22 12:09 SupervisedThinking

For build time I can't check right now but I think you can select the version number of a vcpkg dependency (For actual crypto runtime I don't have a Wii U to extract keys from so I won't be able to test it anyways).

bitscher avatar Sep 01 '22 17:09 bitscher

They are just aliases in both 3.0.5 and 1.1.1g

https://github.com/openssl/openssl/blob/openssl-3.0.5/crypto/ec/ec_lib.c#L919-L935 https://github.com/openssl/openssl/blob/OpenSSL_1_1_1q/crypto/ec/ec_lib.c#L857-L873

So this is really safe.

bitscher avatar Sep 01 '22 17:09 bitscher

The fix for this should really be part of a bigger fix to remove all crypto functions deprecated by OpenSSL 3.0

bitscher avatar Sep 03 '22 20:09 bitscher

The fix for this should really be part of a bigger fix to remove all crypto functions deprecated by OpenSSL 3.0

Indeed but currently you can't build cemu with openssl 3.0 with EC_POINT_get_affine_coordinates_GF2m but it does not fail with EC_POINT_get_affine_coordinates

SupervisedThinking avatar Sep 04 '22 12:09 SupervisedThinking

We now use EC_POINT_get_affine_coordinates instead of EC_POINT_get_affine_coordinates_GF2m and Cemu should compile with OpenSSL that has no-ec2m flag set

Exzap avatar Nov 05 '22 23:11 Exzap