• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Changing a function on otserv.cpp help please

darknelson

Member
Joined
Jun 19, 2011
Messages
192
Solutions
1
Reaction score
14
hi, im trying to remove this part of code

C++:
    // set RSA key
    try {
        g_RSA.loadPEM("key.pem");
    } catch(const std::exception& e) {
        SPDLOG_ERROR(e.what());
        startupErrorMessage();
    }

and replace it with this

C++:
//set RSA key
    const char* p("14299623962416399520070177382898895550795403345466153217470516082934737582776038882967213386204600674145392845853859217990626450972452084065728686565928113");
    const char* q("7630979195970404721891201847792002125535401292779123937207447574596692788513647179235335529307251350570728407373705564708871762033017096809910315212884101");
    g_RSA.setKey(p, q);

but it gives me an error on compile, please help how to implement that change



Error C2039 'setKey': is not a member of 'RSA2'
 

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,760
Solutions
9
Reaction score
282
Location
Chile
hi, im trying to remove this part of code

C++:
    // set RSA key
    try {
        g_RSA.loadPEM("key.pem");
    } catch(const std::exception& e) {
        SPDLOG_ERROR(e.what());
        startupErrorMessage();
    }

and replace it with this

C++:
//set RSA key
    const char* p("14299623962416399520070177382898895550795403345466153217470516082934737582776038882967213386204600674145392845853859217990626450972452084065728686565928113");
    const char* q("7630979195970404721891201847792002125535401292779123937207447574596692788513647179235335529307251350570728407373705564708871762033017096809910315212884101");
    g_RSA.setKey(p, q);

but it gives me an error on compile, please help how to implement that change



Error C2039 'setKey': is not a member of 'RSA2'
if you want to change the rsa then edit the file keypem
 

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
899
Solutions
21
Reaction score
429
Location
Santiago - Chile
@darknelson After reverting this Load RSA private key from PEM file (#2496) · otland/[email protected] (https://github.com/otland/forgottenserver/commit/1e044c4c4ea45f674d75d7b56c9086f6fd9e65d7)
You can generate an RSA key here VAPus - TFS RSA Generator (https://web.archive.org/web/20120423030928/http://vapus.net/generatersa)

Then go here, and edit const char* p as rsaPrime1, and const char* q as rsaPrime2
Code:
    const char* p("14299623962416399520070177382898895550795403345466153217470516082934737582776038882967213386204600674145392845853859217990626450972452084065728686565928113");
    const char* q("7630979195970404721891201847792002125535401292779123937207447574596692788513647179235335529307251350570728407373705564708871762033017096809910315212884101");
    g_RSA.setKey(p, q);

Then go to OTClient and search for
https://github.com/mehah/otclient/blob/cache-for-all/modules/gamelib/const.lua#L227-L231

You have to set rsaModulus in OTSERV_RSA. It is supposed that TFS calculates rsaPrivate (const char* d) automatically based on * p and *q

Code:
rsaPrime1 = p
rsaPrime2 = q
rsaPrivate = d
rsaModulus = OTSERV_RSA

Hope this works.
Regards!
 
Last edited:
OP
OP
D

darknelson

Member
Joined
Jun 19, 2011
Messages
192
Solutions
1
Reaction score
14
Already done it bro

but the problem shows up

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'gmp.h': No such file or directory D:\Descargas\Compressed\otservbr-global-develop\otservbr-global-develop\out\build\x64-Release\otservbr-global-develop D:\Descargas\Compressed\otservbr-global-develop\otservbr-global-develop\src\rsa.h 23


dont know why and how to solve, maybe gmp.h file is missing from sources, ? maybe need other lib?
 

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
899
Solutions
21
Reaction score
429
Location
Santiago - Chile
Already done it bro

but the problem shows up

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'gmp.h': No such file or directory D:\Descargas\Compressed\otservbr-global-develop\otservbr-global-develop\out\build\x64-Release\otservbr-global-develop D:\Descargas\Compressed\otservbr-global-develop\otservbr-global-develop\src\rsa.h 23


dont know why and how to solve, maybe gmp.h file is missing from sources, ? maybe need other lib?
You're missing GMP lib The GNU MP Bignum Library (https://gmplib.org/)
I need to know first if you're using vcpkg or boost libraries to compile.

If you're using boosts be sure to link well and be sure that your'e compiling for x64 or x86 with the correct libs Compiling TFS 1.0/1.1 latest source. 64 and 32 bits. Pics and lots of explanation. (https://otland.net/threads/compiling-tfs-1-0-1-1-latest-source-64-and-32-bits-pics-and-lots-of-explanation.204532/#post-1963215)

That thread FAQ say it
dominique120 said:
Q: I get "missing something/something.h" errors.
A: You probably did not let it parse completely or you did not link properly.

If you use vcpkg, this could work
Code:
apt-get install libgmp10 libgmp-dev
sudo apt-get install libmpfr-dev

Also check if vcpkg install is updated
Code:
git pull
vcpkg remove --outdated --recurse
bootstrap-vcpkg.bat
vcpkg update
vcpkg upgrade --no-dry-run
Then
Code:
vcpkg install --triplet x64-windows boost-iostreams boost-asio boost-system boost-filesystem boost-variant boost-lockfree luajit libmariadb pugixml cryptopp
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
 
Last edited:
OP
OP
D

darknelson

Member
Joined
Jun 19, 2011
Messages
192
Solutions
1
Reaction score
14
everything is ok, i followed all this steps, before compiling, also fixed some error with nuget.org and package manager, but still showing me that error


thats the steps i followed, there is a way to fix it? also i have gmp.h extracted from a tfs 1.0 sfdk but i dont know where to put it manually, please help me with that, also i cant download the lib with nuget cause the project has no name when i opened it like folder. please help
 

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
899
Solutions
21
Reaction score
429
Location
Santiago - Chile
 

Attachments

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,973
Solutions
206
Reaction score
3,813
Top