Skip to content

Commit

Permalink
Make compatible with [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleLabyrinth committed Nov 22, 2019
1 parent e61b0f9 commit 599ac96
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/RSACipher.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <openssl/opensslv.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/bio.h>
Expand Down Expand Up @@ -93,12 +94,18 @@ class RSACipher {

[[nodiscard]]
size_t Bits() const {
#if (OPENSSL_VERSION_NUMBER & 0xffff0000) == 0x10000000 // openssl 1.0.x
if (pvt_RsaObj->n == nullptr) {
// NOLINTNEXTLINE: allow exceptions that is not derived from std::exception
throw nkg::Exception(__FILE__, __LINE__, "RSA modulus has not been set.");
} else {
return BN_num_bits(pvt_RsaObj->n);
}
#elif (OPENSSL_VERSION_NUMBER & 0xffff0000) == 0x10100000 // openssl 1.1.x
return RSA_bits(pvt_RsaObj);
#else
#error "Unexpected openssl version!"
#endif
}

void GenerateKey(int bits, unsigned int e = RSA_F4) {
Expand Down

0 comments on commit 599ac96

Please sign in to comment.