Error RSA compiling executable of a custom game (more info inside)

Hello.

I'm compiling in debian 9 an ejecutable of otx (a custom version of tfs, open tibia, an open version of the 1997 mmorpg game called tibia). This OTX is similar than tibia but the custom content includes pokemon or dragon ball datapacks.

This is the official gib:

https://github.com/mattyx14/otxserver

And this is how to compile in linux:

https://github.com/mattyx14/otxserver/wiki/Compilling-on-Linux

I have installed all libs unless libmysqlclient-dev because I'm using debian 9 and it works with libmariadb.

Error compiling:

otserv.cpp:614:18: error: invalid use of incomplete type âRSA {aka struct rsa_st}â
BN_dec2bn(&g_RSA->q, g_config.getString(ConfigManager::RSA_PRIME2).c_str());

Lines from 613 to 617:

BN_dec2bn(&g_RSA->p, g_config.getString(ConfigManager::RSA_PRIME1).c_str());
BN_dec2bn(&g_RSA->q, g_config.getString(ConfigManager::RSA_PRIME2).c_str());
BN_dec2bn(&g_RSA->d, g_config.getString(ConfigManager::RSA_PRIVATE).c_str());
BN_dec2bn(&g_RSA->n, g_config.getString(ConfigManager::RSA_MODULUS).c_str());
BN_dec2bn(&g_RSA->e, g_config.getString(ConfigManager::RSA_PUBLIC).c_str());

Lines 627, 628 and 630:

BN_mod(g_RSA->dmp1, g_RSA->d, r1, ctx);
BN_mod(g_RSA->dmq1, g_RSA->d, r2, ctx);

BN_mod_inverse(g_RSA->iqmp, g_RSA->q, g_RSA->p, ctx);


I have openssl 1.1 installed. I say this because it said something about openssl too.

I have tried to open an issue there but they close it without paying much attention.
Last edited on
¿version and patch?

seems that your openssl is too new
https://github.com/openssl/openssl/issues/1604
https://manpages.debian.org/unstable/libssl-doc/RSA_get0_key.3ssl.en.html
1
2
//&g_RSA->q
RSA_get0_q(g_RSA)
Hello.

You mean version and patch of OTX? Well, is a custom one I've bought to a guy. Sources are similar, I have to compile doing this:

apt-get install autoconf build-essential pkg-config automake libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libmysqlclient-dev libssl-dev libsqlite3-dev
cd /3777-master
chmod -R 777 src
cd src
./autogen.sh
./configure --enable-mysql --enable-root-permission --enable-server-diag
./build.sh


I can share somehow if you want. I know it worked since it was one of the best otx games in the time but it closed (so now I have bought it trying to re-open it). It doesnt have the executable because they used windows so there is an exe and all msvc files.

I have read the links but I dont draw any conclusion... should I use RSA_get0_q(g_RSA)
instead of &g_RSA->q? What about these three lines?

BN_mod(g_RSA->dmp1, g_RSA->d, r1, ctx);
BN_mod(g_RSA->dmq1, g_RSA->d, r2, ctx);
BN_mod_inverse(g_RSA->iqmp, g_RSA->q, g_RSA->p, ctx);

In that issues they told me this "This could be a problem with your libs, try installing openssl 1.0.2" but I read that change openssl version is not easy to do for a new person in Linux and it was even not recommended... I've posted this in like 5 or 6 forums and nobody knows what to do.

Thanks.
> should I use RSA_get0_q(g_RSA) instead of &g_RSA->q?
yep, they dropped direct access so now have to use the interface.
RSA_get*() and RSA_set*() functions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
BN_mod(g_RSA->dmp1, g_RSA->d, r1, ctx);
BN_mod(g_RSA->dmq1, g_RSA->d, r2, ctx);
BN_mod_inverse(g_RSA->iqmp, g_RSA->q, g_RSA->p, ctx);

BN_mod(
	RSA_get0_dmp1(g_RSA),
	RSA_get0_d(g_RSA),
	r1,
	ctx
);
BN_mod(
	RSA_get0_dmp1(g_RSA),
	RSA_get0_d(g_RSA),
	r2,
	ctx
);
BN_mod_inverse(
	RSA_get0_iqmp(g_RSA),
	RSA_get0_q(g_RSA),
	RSA_get0_p(g_RSA),
	ctx
);


> You mean version and patch of OTX? Well, is a custom one I've bought to a guy.
> Sources are similar
the one from github has version 2 and 3, and then they have path_{10,7,8} want to know which of all of them you are compiling.
This is the error I got now:

--------------------------------------------------------------------------------------------------------


CXX otserv.o
otserv.cpp: In function âvoid otserv(StringVec, ServiceManager*)â:
otserv.cpp:613:28: error: âRSA_get0_pâ was not declared in this scope
BN_dec2bn(RSA_get0_p(g_RSA), g_config.getString(ConfigManager::RSA_PRIME1).c_str());
^
otserv.cpp:614:28: error: âRSA_get0_qâ was not declared in this scope
BN_dec2bn(RSA_get0_q(g_RSA), g_config.getString(ConfigManager::RSA_PRIME2).c_str());
^
otserv.cpp:615:28: error: âRSA_get0_dâ was not declared in this scope
BN_dec2bn(RSA_get0_d(g_RSA), g_config.getString(ConfigManager::RSA_PRIVATE).c_str());
^
otserv.cpp:616:28: error: âRSA_get0_nâ was not declared in this scope
BN_dec2bn(RSA_get0_n(g_RSA), g_config.getString(ConfigManager::RSA_MODULUS).c_str());
^
otserv.cpp:617:28: error: âRSA_get0_eâ was not declared in this scope
BN_dec2bn(RSA_get0_e(g_RSA), g_config.getString(ConfigManager::RSA_PUBLIC).c_str());
^
In file included from /usr/include/openssl/asn1.h:24:0,
from /usr/include/openssl/rsa.h:16,
from otserv.cpp:44:
otserv.cpp:628:21: error: âRSA_get0_dmp1â was not declared in this scope
RSA_get0_dmp1(g_RSA),
^
otserv.cpp:641:21: error: âRSA_get0_iqmpâ was not declared in this scope
RSA_get0_iqmp(g_RSA),
^
Makefile:565: fallo en las instrucciones para el objetivo 'otserv.o'
make[1]: *** [otserv.o] Error 1


--------------------------------------------------------------------------------------------------------

I changed the lines as you told me:

BN_dec2bn(RSA_get0_p(g_RSA), g_config.getString(ConfigManager::RSA_PRIME1).c_str());
BN_dec2bn(RSA_get0_q(g_RSA), g_config.getString(ConfigManager::RSA_PRIME2).c_str());
BN_dec2bn(RSA_get0_d(g_RSA), g_config.getString(ConfigManager::RSA_PRIVATE).c_str());
BN_dec2bn(RSA_get0_n(g_RSA), g_config.getString(ConfigManager::RSA_MODULUS).c_str());
BN_dec2bn(RSA_get0_e(g_RSA), g_config.getString(ConfigManager::RSA_PUBLIC).c_str());

-----------

BN_mod(
RSA_get0_dmp1(g_RSA),
RSA_get0_d(g_RSA),
r1,
ctx
);
BN_mod(
RSA_get0_dmp1(g_RSA),
RSA_get0_d(g_RSA),
r2,
ctx
);

BN_mod_inverse(
RSA_get0_iqmp(g_RSA),
RSA_get0_q(g_RSA),
RSA_get0_p(g_RSA),
ctx
);


------------------------------------------------------------------------


I have taken the liberty of sending you via pm the sources I have for this executable without editing anything nor any line. The "problem" file is otserv.cpp

Thanks in advice.

Registered users can post here. Sign in or register to post.