Skip to content

Commit

Permalink
added support of openssl 1.1 in STL version
Browse files Browse the repository at this point in the history
direct access to RSA struct members replaced with RSA_* calls
  • Loading branch information
aesilevich committed Dec 30, 2019
1 parent d20b41f commit 058cb26
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions Source/STL/AquaticPrime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ bool APSetKey(std::string key)

// Create a new key
rsaKey = RSA_new();

// Public exponent is always 3
BN_hex2bn(&rsaKey->e, "3");

BIGNUM * e = BN_new();
BIGNUM * n = BN_new();

// Public exponent is always 3
BN_hex2bn(&e, "3");

std::string mutableKey = key;

Expand All @@ -74,13 +77,20 @@ bool APSetKey(std::string key)
if(std::string(mutableKey, 0, 2) == "0x")
{
mutableKey = std::string(mutableKey, 2, mutableKey.length());
BN_hex2bn(&rsaKey->n, mutableKey.c_str());
BN_hex2bn(&n, mutableKey.c_str());
}
else
{
BN_dec2bn(&rsaKey->n, mutableKey.c_str());
BN_dec2bn(&n, mutableKey.c_str());
}


#if OPENSSL_VERSION_NUMBER < 0x10100000L
rsaKey->n = n;
rsaKey->e = e;
#else
RSA_set0_key(rsaKey, n, e, nullptr);
#endif

return true;
}

Expand All @@ -107,7 +117,18 @@ void APBlacklistAdd(std::string blacklistEntry)

std::map<std::string, std::string> APCreateDictionaryForLicenseData(std::map<std::string, std::string> data)
{
if (!rsaKey->n || !rsaKey->e)
const BIGNUM * n = nullptr;
const BIGNUM * e = nullptr;

#if OPENSSL_VERSION_NUMBER < 0x10100000L
n = rsaKey->n;
e = rsaKey->e;
#else
const BIGNUM * d = nullptr;
RSA_get0_key(rsaKey, &n, &e, &d);
#endif

if (!n || !e)
{
std::map<std::string, std::string> empty;
printf("0\n");
Expand Down

0 comments on commit 058cb26

Please sign in to comment.