Advertisement
KukuRuzo

qca fix codestyle

May 10th, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.76 KB | None | 0 0
  1. diff --git a/plugins/qca-ossl/dhkey.cpp b/plugins/qca-ossl/dhkey.cpp
  2. index 976806e3..89d45bc4 100644
  3. --- a/plugins/qca-ossl/dhkey.cpp
  4. +++ b/plugins/qca-ossl/dhkey.cpp
  5. @@ -33,7 +33,7 @@ class DHKeyMaker : public QThread
  6.      Q_OBJECT
  7.  public:
  8.      DLGroup domain;
  9. -    DH *    result;
  10. +    DH     *result;
  11.  
  12.      DHKeyMaker(const DLGroup &_domain, QObject *parent = nullptr)
  13.          : QThread(parent)
  14. @@ -51,7 +51,7 @@ public:
  15.  
  16.      void run() override
  17.      {
  18. -        DH *    dh  = DH_new();
  19. +        DH     *dh  = DH_new();
  20.          BIGNUM *bnp = bi2bn(domain.p());
  21.          BIGNUM *bng = bi2bn(domain.g());
  22.          if (!DH_set0_pqg(dh, bnp, nullptr, bng) || !DH_generate_key(dh)) {
  23. @@ -119,8 +119,8 @@ void DHKey::convertToPublic()
  24.      if (!sec)
  25.          return;
  26.  
  27. -    DH *          orig = EVP_PKEY_get0_DH(evp.pkey);
  28. -    DH *          dh   = DH_new();
  29. +    const DH     *orig = EVP_PKEY_get0_DH(evp.pkey);
  30. +    DH           *dh   = DH_new();
  31.      const BIGNUM *bnp, *bng, *bnpub_key;
  32.      DH_get0_pqg(orig, &bnp, nullptr, &bng);
  33.      DH_get0_key(orig, &bnpub_key, nullptr);
  34. @@ -142,13 +142,13 @@ int DHKey::bits() const
  35.  
  36.  SymmetricKey DHKey::deriveKey(const PKeyBase &theirs)
  37.  {
  38. -    DH *          dh   = EVP_PKEY_get0_DH(evp.pkey);
  39. -    DH *          them = EVP_PKEY_get0_DH(static_cast<const DHKey *>(&theirs)->evp.pkey);
  40. +    const DH     *dh   = EVP_PKEY_get0_DH(evp.pkey);
  41. +    const DH     *them = EVP_PKEY_get0_DH(static_cast<const DHKey *>(&theirs)->evp.pkey);
  42.      const BIGNUM *bnpub_key;
  43.      DH_get0_key(them, &bnpub_key, nullptr);
  44.  
  45.      SecureArray result(DH_size(dh));
  46. -    int         ret = DH_compute_key((unsigned char *)result.data(), bnpub_key, dh);
  47. +    int         ret = DH_compute_key((unsigned char *)result.data(), bnpub_key, (DH *)dh);
  48.      if (ret <= 0)
  49.          return SymmetricKey();
  50.      result.resize(ret);
  51. @@ -174,7 +174,7 @@ void DHKey::createPrivate(const DLGroup &domain, const BigInteger &y, const BigI
  52.  {
  53.      evp.reset();
  54.  
  55. -    DH *    dh         = DH_new();
  56. +    DH     *dh         = DH_new();
  57.      BIGNUM *bnp        = bi2bn(domain.p());
  58.      BIGNUM *bng        = bi2bn(domain.g());
  59.      BIGNUM *bnpub_key  = bi2bn(y);
  60. @@ -194,7 +194,7 @@ void DHKey::createPublic(const DLGroup &domain, const BigInteger &y)
  61.  {
  62.      evp.reset();
  63.  
  64. -    DH *    dh        = DH_new();
  65. +    DH     *dh        = DH_new();
  66.      BIGNUM *bnp       = bi2bn(domain.p());
  67.      BIGNUM *bng       = bi2bn(domain.g());
  68.      BIGNUM *bnpub_key = bi2bn(y);
  69. @@ -211,7 +211,7 @@ void DHKey::createPublic(const DLGroup &domain, const BigInteger &y)
  70.  
  71.  DLGroup DHKey::domain() const
  72.  {
  73. -    DH *          dh = EVP_PKEY_get0_DH(evp.pkey);
  74. +    const DH     *dh = EVP_PKEY_get0_DH(evp.pkey);
  75.      const BIGNUM *bnp, *bng;
  76.      DH_get0_pqg(dh, &bnp, nullptr, &bng);
  77.      return DLGroup(bn2bi(bnp), bn2bi(bng));
  78. @@ -219,7 +219,7 @@ DLGroup DHKey::domain() const
  79.  
  80.  BigInteger DHKey::y() const
  81.  {
  82. -    DH *          dh = EVP_PKEY_get0_DH(evp.pkey);
  83. +    const DH     *dh = EVP_PKEY_get0_DH(evp.pkey);
  84.      const BIGNUM *bnpub_key;
  85.      DH_get0_key(dh, &bnpub_key, nullptr);
  86.      return bn2bi(bnpub_key);
  87. @@ -227,7 +227,7 @@ BigInteger DHKey::y() const
  88.  
  89.  BigInteger DHKey::x() const
  90.  {
  91. -    DH *          dh = EVP_PKEY_get0_DH(evp.pkey);
  92. +    const DH     *dh = EVP_PKEY_get0_DH(evp.pkey);
  93.      const BIGNUM *bnpriv_key;
  94.      DH_get0_key(dh, nullptr, &bnpriv_key);
  95.      return bn2bi(bnpriv_key);
  96. diff --git a/plugins/qca-ossl/dsakey.cpp b/plugins/qca-ossl/dsakey.cpp
  97. index 6dff69c5..8281b775 100644
  98. --- a/plugins/qca-ossl/dsakey.cpp
  99. +++ b/plugins/qca-ossl/dsakey.cpp
  100. @@ -23,6 +23,13 @@
  101.  #include "dsakey.h"
  102.  #include "utils.h"
  103.  
  104. +namespace {
  105. +static const auto DsaDeleter = [](DSA *pointer) {
  106. +    if (pointer)
  107. +        DSA_free((DSA *)pointer);
  108. +};
  109. +} // end of anonymous namespace
  110. +
  111.  namespace opensslQCAPlugin {
  112.  
  113.  // take lowest bytes of BIGNUM to fit
  114. @@ -41,7 +48,7 @@ static SecureArray bn2fixedbuf(const BIGNUM *n, int size)
  115.  
  116.  static SecureArray dsasig_der_to_raw(const SecureArray &in)
  117.  {
  118. -    DSA_SIG *            sig = DSA_SIG_new();
  119. +    DSA_SIG             *sig = DSA_SIG_new();
  120.      const unsigned char *inp = (const unsigned char *)in.data();
  121.      d2i_DSA_SIG(&sig, &inp, in.size());
  122.  
  123. @@ -63,11 +70,11 @@ static SecureArray dsasig_raw_to_der(const SecureArray &in)
  124.      if (in.size() != 40)
  125.          return SecureArray();
  126.  
  127. -    DSA_SIG *   sig = DSA_SIG_new();
  128. +    DSA_SIG    *sig = DSA_SIG_new();
  129.      SecureArray part_r(20);
  130. -    BIGNUM *    bnr;
  131. +    BIGNUM     *bnr;
  132.      SecureArray part_s(20);
  133. -    BIGNUM *    bns;
  134. +    BIGNUM     *bns;
  135.      memcpy(part_r.data(), in.data(), 20);
  136.      memcpy(part_s.data(), in.data() + 20, 20);
  137.      bnr = BN_bin2bn((const unsigned char *)part_r.data(), part_r.size(), nullptr);
  138. @@ -94,7 +101,7 @@ class DSAKeyMaker : public QThread
  139.      Q_OBJECT
  140.  public:
  141.      DLGroup domain;
  142. -    DSA *   result;
  143. +    DSA    *result;
  144.  
  145.      DSAKeyMaker(const DLGroup &_domain, QObject *parent = nullptr)
  146.          : QThread(parent)
  147. @@ -112,14 +119,47 @@ public:
  148.  
  149.      void run() override
  150.      {
  151. -        DSA *   dsa = DSA_new();
  152. +        std::unique_ptr<DSA, decltype(DsaDeleter)> dsa(DSA_new(), DsaDeleter);
  153.          BIGNUM *pne = bi2bn(domain.p()), *qne = bi2bn(domain.q()), *gne = bi2bn(domain.g());
  154.  
  155. -        if (!DSA_set0_pqg(dsa, pne, qne, gne) || !DSA_generate_key(dsa)) {
  156. -            DSA_free(dsa);
  157. +        if (!DSA_set0_pqg(dsa.get(), pne, qne, gne)) {
  158. +            return;
  159. +        }
  160. +        if (!DSA_generate_key(dsa.get())) {
  161. +            // OPENSSL_VERSION_MAJOR is only defined in openssl3
  162. +#ifdef OPENSSL_VERSION_MAJOR
  163. +            // HACK
  164. +            // in openssl3 there is an internal flag for "legacy" values
  165. +            //      bits < 2048 && seed_len <= 20
  166. +            // set in ossl_ffc_params_FIPS186_2_generate (called by DSA_generate_parameters_ex)
  167. +            // that we have no way to get or set, so if the bits are smaller than 2048 we generate
  168. +            // a dsa from a dummy seed and then override the p/q/g with the ones we want
  169. +            // so we can reuse the internal flag
  170. +            if (BN_num_bits(pne) < 2048) {
  171. +                int dummy;
  172. +                dsa.reset(DSA_new());
  173. +                if (DSA_generate_parameters_ex(
  174. +                        dsa.get(), 512, (const unsigned char *)"THIS_IS_A_DUMMY_SEED", 20, &dummy, nullptr, nullptr) !=
  175. +                    1) {
  176. +                    return;
  177. +                }
  178. +                pne = bi2bn(domain.p());
  179. +                qne = bi2bn(domain.q());
  180. +                gne = bi2bn(domain.g());
  181. +                if (!DSA_set0_pqg(dsa.get(), pne, qne, gne)) {
  182. +                    return;
  183. +                }
  184. +                if (!DSA_generate_key(dsa.get())) {
  185. +                    return;
  186. +                }
  187. +            } else {
  188. +                return;
  189. +            }
  190. +#else
  191.              return;
  192. +#endif
  193.          }
  194. -        result = dsa;
  195. +        result = dsa.release();
  196.      }
  197.  
  198.      DSA *takeResult()
  199. @@ -181,7 +221,7 @@ void DSAKey::convertToPublic()
  200.          return;
  201.  
  202.      // extract the public key into DER format
  203. -    DSA *          dsa_pkey = EVP_PKEY_get0_DSA(evp.pkey);
  204. +    const DSA     *dsa_pkey = EVP_PKEY_get0_DSA(evp.pkey);
  205.      int            len      = i2d_DSAPublicKey(dsa_pkey, nullptr);
  206.      SecureArray    result(len);
  207.      unsigned char *p = (unsigned char *)result.data();
  208. @@ -266,7 +306,7 @@ void DSAKey::createPrivate(const DLGroup &domain, const BigInteger &y, const Big
  209.  {
  210.      evp.reset();
  211.  
  212. -    DSA *   dsa        = DSA_new();
  213. +    DSA    *dsa        = DSA_new();
  214.      BIGNUM *bnp        = bi2bn(domain.p());
  215.      BIGNUM *bnq        = bi2bn(domain.q());
  216.      BIGNUM *bng        = bi2bn(domain.g());
  217. @@ -287,7 +327,7 @@ void DSAKey::createPublic(const DLGroup &domain, const BigInteger &y)
  218.  {
  219.      evp.reset();
  220.  
  221. -    DSA *   dsa       = DSA_new();
  222. +    DSA    *dsa       = DSA_new();
  223.      BIGNUM *bnp       = bi2bn(domain.p());
  224.      BIGNUM *bnq       = bi2bn(domain.q());
  225.      BIGNUM *bng       = bi2bn(domain.g());
  226. @@ -305,7 +345,7 @@ void DSAKey::createPublic(const DLGroup &domain, const BigInteger &y)
  227.  
  228.  DLGroup DSAKey::domain() const
  229.  {
  230. -    DSA *         dsa = EVP_PKEY_get0_DSA(evp.pkey);
  231. +    const DSA    *dsa = EVP_PKEY_get0_DSA(evp.pkey);
  232.      const BIGNUM *bnp, *bnq, *bng;
  233.      DSA_get0_pqg(dsa, &bnp, &bnq, &bng);
  234.      return DLGroup(bn2bi(bnp), bn2bi(bnq), bn2bi(bng));
  235. @@ -313,7 +353,7 @@ DLGroup DSAKey::domain() const
  236.  
  237.  BigInteger DSAKey::y() const
  238.  {
  239. -    DSA *         dsa = EVP_PKEY_get0_DSA(evp.pkey);
  240. +    const DSA    *dsa = EVP_PKEY_get0_DSA(evp.pkey);
  241.      const BIGNUM *bnpub_key;
  242.      DSA_get0_key(dsa, &bnpub_key, nullptr);
  243.      return bn2bi(bnpub_key);
  244. @@ -321,7 +361,7 @@ BigInteger DSAKey::y() const
  245.  
  246.  BigInteger DSAKey::x() const
  247.  {
  248. -    DSA *         dsa = EVP_PKEY_get0_DSA(evp.pkey);
  249. +    const DSA    *dsa = EVP_PKEY_get0_DSA(evp.pkey);
  250.      const BIGNUM *bnpriv_key;
  251.      DSA_get0_key(dsa, nullptr, &bnpriv_key);
  252.      return bn2bi(bnpriv_key);
  253. diff --git a/plugins/qca-ossl/evpkey.cpp b/plugins/qca-ossl/evpkey.cpp
  254. index cae1a901..cde5a509 100644
  255. --- a/plugins/qca-ossl/evpkey.cpp
  256. +++ b/plugins/qca-ossl/evpkey.cpp
  257. @@ -111,10 +111,12 @@ SecureArray EVPKey::endSign()
  258.              int type = EVP_PKEY_id(pkey);
  259.  
  260.              if (type == EVP_PKEY_RSA) {
  261. -                RSA *rsa = EVP_PKEY_get0_RSA(pkey);
  262. -                if (RSA_private_encrypt(
  263. -                        raw.size(), (unsigned char *)raw.data(), (unsigned char *)out.data(), rsa, RSA_PKCS1_PADDING) ==
  264. -                    -1) {
  265. +                const RSA *rsa = EVP_PKEY_get0_RSA(pkey);
  266. +                if (RSA_private_encrypt(raw.size(),
  267. +                                        (unsigned char *)raw.data(),
  268. +                                        (unsigned char *)out.data(),
  269. +                                        (RSA *)rsa,
  270. +                                        RSA_PKCS1_PADDING) == -1) {
  271.                      state = SignError;
  272.                      return SecureArray();
  273.                  }
  274. @@ -148,11 +150,11 @@ bool EVPKey::endVerify(const SecureArray &sig)
  275.              int type = EVP_PKEY_id(pkey);
  276.  
  277.              if (type == EVP_PKEY_RSA) {
  278. -                RSA *rsa = EVP_PKEY_get0_RSA(pkey);
  279. +                const RSA *rsa = EVP_PKEY_get0_RSA(pkey);
  280.                  if ((len = RSA_public_decrypt(sig.size(),
  281.                                                (unsigned char *)sig.data(),
  282.                                                (unsigned char *)out.data(),
  283. -                                              rsa,
  284. +                                              (RSA *)rsa,
  285.                                                RSA_PKCS1_PADDING)) == -1) {
  286.                      state = VerifyError;
  287.                      return false;
  288. diff --git a/plugins/qca-ossl/qca-ossl.cpp b/plugins/qca-ossl/qca-ossl.cpp
  289. index 3df47a65..b9602f7f 100644
  290. --- a/plugins/qca-ossl/qca-ossl.cpp
  291. +++ b/plugins/qca-ossl/qca-ossl.cpp
  292. @@ -48,11 +48,15 @@
  293.  #include <memory>
  294.  
  295.  #include <openssl/err.h>
  296. +#include <openssl/opensslv.h>
  297.  #include <openssl/pem.h>
  298.  #include <openssl/pkcs12.h>
  299.  #include <openssl/rand.h>
  300.  #include <openssl/ssl.h>
  301.  #include <openssl/x509v3.h>
  302. +#ifdef OPENSSL_VERSION_MAJOR
  303. +#include <openssl/provider.h>
  304. +#endif
  305.  
  306.  #ifndef LIBRESSL_VERSION_NUMBER
  307.  #include <openssl/kdf.h>
  308. @@ -447,9 +451,9 @@ public:
  309.          EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, nullptr);
  310.          EVP_PKEY_derive_init(pctx);
  311.          EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256());
  312. -        EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt.data(), int(salt.size()));
  313. -        EVP_PKEY_CTX_set1_hkdf_key(pctx, secret.data(), int(secret.size()));
  314. -        EVP_PKEY_CTX_add1_hkdf_info(pctx, info.data(), int(info.size()));
  315. +        EVP_PKEY_CTX_set1_hkdf_salt(pctx, (const unsigned char *)salt.data(), int(salt.size()));
  316. +        EVP_PKEY_CTX_set1_hkdf_key(pctx, (const unsigned char *)secret.data(), int(secret.size()));
  317. +        EVP_PKEY_CTX_add1_hkdf_info(pctx, (const unsigned char *)info.data(), int(info.size()));
  318.          size_t outlen = out.size();
  319.          EVP_PKEY_derive(pctx, reinterpret_cast<unsigned char *>(out.data()), &outlen);
  320.          EVP_PKEY_CTX_free(pctx);
  321. diff --git a/plugins/qca-ossl/rsakey.cpp b/plugins/qca-ossl/rsakey.cpp
  322. index 447e9cdb..a2e26fa7 100644
  323. --- a/plugins/qca-ossl/rsakey.cpp
  324. +++ b/plugins/qca-ossl/rsakey.cpp
  325. @@ -78,8 +78,9 @@ public:
  326.          if (BN_set_word(e.get(), exp) != 1)
  327.              return;
  328.  
  329. -        if (RSA_generate_key_ex(rsa.get(), bits, e.get(), nullptr) == 0)
  330. +        if (RSA_generate_key_ex(rsa.get(), bits, e.get(), nullptr) == 0) {
  331.              return;
  332. +        }
  333.  
  334.          result = rsa.release();
  335.      }
  336. @@ -143,7 +144,7 @@ void RSAKey::convertToPublic()
  337.          return;
  338.  
  339.      // extract the public key into DER format
  340. -    RSA *          rsa_pkey = EVP_PKEY_get0_RSA(evp.pkey);
  341. +    const RSA     *rsa_pkey = EVP_PKEY_get0_RSA(evp.pkey);
  342.      int            len      = i2d_RSAPublicKey(rsa_pkey, nullptr);
  343.      SecureArray    result(len);
  344.      unsigned char *p = (unsigned char *)result.data();
  345. @@ -165,8 +166,8 @@ int RSAKey::bits() const
  346.  
  347.  int RSAKey::maximumEncryptSize(EncryptionAlgorithm alg) const
  348.  {
  349. -    RSA *rsa  = EVP_PKEY_get0_RSA(evp.pkey);
  350. -    int  size = 0;
  351. +    const RSA *rsa  = EVP_PKEY_get0_RSA(evp.pkey);
  352. +    int        size = 0;
  353.      switch (alg) {
  354.      case EME_PKCS1v15:
  355.          size = RSA_size(rsa) - 11 - 1;
  356. @@ -187,7 +188,7 @@ int RSAKey::maximumEncryptSize(EncryptionAlgorithm alg) const
  357.  
  358.  SecureArray RSAKey::encrypt(const SecureArray &in, EncryptionAlgorithm alg)
  359.  {
  360. -    RSA *       rsa = EVP_PKEY_get0_RSA(evp.pkey);
  361. +    const RSA  *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  362.      SecureArray buf = in;
  363.      int         max = maximumEncryptSize(alg);
  364.  
  365. @@ -203,9 +204,11 @@ SecureArray RSAKey::encrypt(const SecureArray &in, EncryptionAlgorithm alg)
  366.      case EME_PKCS1_OAEP:
  367.          pad = RSA_PKCS1_OAEP_PADDING;
  368.          break;
  369. +#ifdef RSA_SSLV23_PADDING
  370.      case EME_PKCS1v15_SSL:
  371.          pad = RSA_SSLV23_PADDING;
  372.          break;
  373. +#endif
  374.      case EME_NO_PADDING:
  375.          pad = RSA_NO_PADDING;
  376.          break;
  377. @@ -216,9 +219,11 @@ SecureArray RSAKey::encrypt(const SecureArray &in, EncryptionAlgorithm alg)
  378.  
  379.      int ret;
  380.      if (isPrivate())
  381. -        ret = RSA_private_encrypt(buf.size(), (unsigned char *)buf.data(), (unsigned char *)result.data(), rsa, pad);
  382. +        ret = RSA_private_encrypt(
  383. +            buf.size(), (unsigned char *)buf.data(), (unsigned char *)result.data(), (RSA *)rsa, pad);
  384.      else
  385. -        ret = RSA_public_encrypt(buf.size(), (unsigned char *)buf.data(), (unsigned char *)result.data(), rsa, pad);
  386. +        ret = RSA_public_encrypt(
  387. +            buf.size(), (unsigned char *)buf.data(), (unsigned char *)result.data(), (RSA *)rsa, pad);
  388.  
  389.      if (ret < 0)
  390.          return SecureArray();
  391. @@ -229,7 +234,7 @@ SecureArray RSAKey::encrypt(const SecureArray &in, EncryptionAlgorithm alg)
  392.  
  393.  bool RSAKey::decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg)
  394.  {
  395. -    RSA *       rsa = EVP_PKEY_get0_RSA(evp.pkey);
  396. +    const RSA  *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  397.      SecureArray result(RSA_size(rsa));
  398.      int         pad;
  399.  
  400. @@ -240,9 +245,11 @@ bool RSAKey::decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorith
  401.      case EME_PKCS1_OAEP:
  402.          pad = RSA_PKCS1_OAEP_PADDING;
  403.          break;
  404. +#ifdef RSA_SSLV23_PADDING
  405.      case EME_PKCS1v15_SSL:
  406.          pad = RSA_SSLV23_PADDING;
  407.          break;
  408. +#endif
  409.      case EME_NO_PADDING:
  410.          pad = RSA_NO_PADDING;
  411.          break;
  412. @@ -253,9 +260,11 @@ bool RSAKey::decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorith
  413.  
  414.      int ret;
  415.      if (isPrivate())
  416. -        ret = RSA_private_decrypt(in.size(), (unsigned char *)in.data(), (unsigned char *)result.data(), rsa, pad);
  417. +        ret =
  418. +            RSA_private_decrypt(in.size(), (unsigned char *)in.data(), (unsigned char *)result.data(), (RSA *)rsa, pad);
  419.      else
  420. -        ret = RSA_public_decrypt(in.size(), (unsigned char *)in.data(), (unsigned char *)result.data(), rsa, pad);
  421. +        ret =
  422. +            RSA_public_decrypt(in.size(), (unsigned char *)in.data(), (unsigned char *)result.data(), (RSA *)rsa, pad);
  423.  
  424.      if (ret < 0)
  425.          return false;
  426. @@ -396,7 +405,7 @@ void RSAKey::createPublic(const BigInteger &n, const BigInteger &e)
  427.  
  428.  BigInteger RSAKey::n() const
  429.  {
  430. -    RSA *         rsa = EVP_PKEY_get0_RSA(evp.pkey);
  431. +    const RSA    *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  432.      const BIGNUM *bnn;
  433.      RSA_get0_key(rsa, &bnn, nullptr, nullptr);
  434.      return bn2bi(bnn);
  435. @@ -404,7 +413,7 @@ BigInteger RSAKey::n() const
  436.  
  437.  BigInteger RSAKey::e() const
  438.  {
  439. -    RSA *         rsa = EVP_PKEY_get0_RSA(evp.pkey);
  440. +    const RSA    *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  441.      const BIGNUM *bne;
  442.      RSA_get0_key(rsa, nullptr, &bne, nullptr);
  443.      return bn2bi(bne);
  444. @@ -412,7 +421,7 @@ BigInteger RSAKey::e() const
  445.  
  446.  BigInteger RSAKey::p() const
  447.  {
  448. -    RSA *         rsa = EVP_PKEY_get0_RSA(evp.pkey);
  449. +    const RSA    *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  450.      const BIGNUM *bnp;
  451.      RSA_get0_factors(rsa, &bnp, nullptr);
  452.      return bn2bi(bnp);
  453. @@ -420,7 +429,7 @@ BigInteger RSAKey::p() const
  454.  
  455.  BigInteger RSAKey::q() const
  456.  {
  457. -    RSA *         rsa = EVP_PKEY_get0_RSA(evp.pkey);
  458. +    const RSA    *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  459.      const BIGNUM *bnq;
  460.      RSA_get0_factors(rsa, nullptr, &bnq);
  461.      return bn2bi(bnq);
  462. @@ -428,7 +437,7 @@ BigInteger RSAKey::q() const
  463.  
  464.  BigInteger RSAKey::d() const
  465.  {
  466. -    RSA *         rsa = EVP_PKEY_get0_RSA(evp.pkey);
  467. +    const RSA    *rsa = EVP_PKEY_get0_RSA(evp.pkey);
  468.      const BIGNUM *bnd;
  469.      RSA_get0_key(rsa, nullptr, nullptr, &bnd);
  470.      return bn2bi(bnd);
  471.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement