Skip to content

Commit

Permalink
Fixes rsa_key::generate_private_key that does not take the parameters…
Browse files Browse the repository at this point in the history
… and go to endless loop.
  • Loading branch information
s-vincent committed Aug 8, 2017
1 parent 51b983a commit db178b0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions libs/cryptoplus/src/rsa_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,22 @@ namespace cryptoplus

rsa_key rsa_key::generate_private_key(int num, unsigned long exponent, generate_callback_type callback, void* callback_arg, bool must_take_ownership)
{
static_cast<void>(num);
static_cast<void>(exponent);
static_cast<void>(callback);
static_cast<void>(callback_arg);
static_cast<void>(callback);
static_cast<void>(callback_arg);

std::unique_ptr<BIGNUM, decltype(&::BN_free)> bn(BN_new(), ::BN_free);
BN_set_word(bn.get(), exponent);

std::unique_ptr<BIGNUM, decltype(&::BN_free)> bn(BN_new(), ::BN_free);
RSA* ptr = nullptr;
rsa_key key = rsa_key::create();
RSA_generate_key_ex(key.raw(), 2048, bn.get(), NULL);
RSA_generate_key_ex(key.raw(), num, bn.get(), NULL);

if (must_take_ownership)
{
return take_ownership(ptr);
return key;
}
else
{
return ptr;
return nullptr;
}
}

Expand Down

0 comments on commit db178b0

Please sign in to comment.