]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Rename (and cleanup) convertToPEM to convertToPEMFile
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 9 Feb 2023 16:34:03 +0000 (17:34 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Tue, 14 Feb 2023 09:09:12 +0000 (10:09 +0100)
pdns/decafsigners.cc
pdns/dnssecinfra.hh
pdns/opensslsigners.cc
pdns/pdnsutil.cc
pdns/sodiumsigners.cc
pdns/test-signers.cc

index 09e25aa7ebafa99b8ac2f8d2b3ed9a9b958024cb..c1fc72663a2317811379f4a6bcd67d62970a0b58 100644 (file)
@@ -48,11 +48,11 @@ public:
    * Receives an open file handle and writes this key's contents to the
    * file.
    *
-   * \param[in] fp An open file handle for writing.
+   * \param[in] outputFile An open file handle for writing.
    *
    * \exception std::runtime_error In case of OpenSSL errors.
    */
-  void convertToPEM(std::FILE& fp) const override;
+  void convertToPEMFile(std::FILE& outputFile) const override;
 #endif
 
   [[nodiscard]] storvector_t convertToISCVector() const override;
@@ -110,14 +110,14 @@ void DecafED25519DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc,
   }
 }
 
-void DecafED25519DNSCryptoKeyEngine::convertToPEM(std::FILE& fp) const
+void DecafED25519DNSCryptoKeyEngine::convertToPEMFile(std::FILE& outputFile) const
 {
   auto key = std::unique_ptr<EVP_PKEY, void (*)(EVP_PKEY*)>(EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, nullptr, d_seckey, DECAF_EDDSA_25519_PRIVATE_BYTES), EVP_PKEY_free);
   if (key == nullptr) {
     throw runtime_error(getName() + ": Could not create private key from buffer");
   }
 
-  auto ret = PEM_write_PrivateKey(&fp, key.get(), nullptr, nullptr, 0, nullptr, nullptr);
+  auto ret = PEM_write_PrivateKey(&outputFile, key.get(), nullptr, nullptr, 0, nullptr, nullptr);
   if (ret == 0) {
     throw runtime_error(getName() + ": Could not convert private key to PEM");
   }
@@ -246,11 +246,11 @@ public:
    * Receives an open file handle and writes this key's contents to the
    * file.
    *
-   * \param[in] fp An open file handle for writing.
+   * \param[in] outputFile An open file handle for writing.
    *
    * \exception std::runtime_error In case of OpenSSL errors.
    */
-  void convertToPEM(std::FILE& fp) const override;
+  void convertToPEMFile(std::FILE& outputFile) const override;
 #endif
 
   storvector_t convertToISCVector() const override;
@@ -308,14 +308,14 @@ void DecafED448DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, c
   }
 }
 
-void DecafED448DNSCryptoKeyEngine::convertToPEM(std::FILE& fp) const
+void DecafED448DNSCryptoKeyEngine::convertToPEMFile(std::FILE& outputFile) const
 {
   auto key = std::unique_ptr<EVP_PKEY, void (*)(EVP_PKEY*)>(EVP_PKEY_new_raw_private_key(EVP_PKEY_ED448, nullptr, d_seckey, DECAF_EDDSA_448_PRIVATE_BYTES), EVP_PKEY_free);
   if (key == nullptr) {
     throw runtime_error(getName() + ": Could not create private key from buffer");
   }
 
-  auto ret = PEM_write_PrivateKey(&fp, key.get(), nullptr, nullptr, 0, nullptr, nullptr);
+  auto ret = PEM_write_PrivateKey(&outputFile, key.get(), nullptr, nullptr, 0, nullptr, nullptr);
   if (ret == 0) {
     throw runtime_error(getName() + ": Could not convert private key to PEM");
   }
index bcba403f4d55fc5ed794c0337c82377b173cba83..6ef5dac6e2e8b6daa0ab2d7ebbeb8c5508e6553f 100644 (file)
@@ -51,7 +51,7 @@ class DNSCryptoKeyEngine
     [[nodiscard]] virtual storvector_t convertToISCVector() const =0;
     [[nodiscard]] std::string convertToISC() const ;
 
-    virtual void convertToPEM(std::FILE& fp) const
+    virtual void convertToPEMFile(std::FILE& /* outputFile */) const
     {
       throw std::runtime_error(getName() + ": Conversion to PEM not supported");
     };
index 94b96ff3e7e305b37855bc0b75750b5171d87e94..5c26c747fc18bdb992d1a4e3914c634296313728 100644 (file)
@@ -239,7 +239,7 @@ public:
    *
    * \exception std::runtime_error In case of OpenSSL errors.
    */
-  void convertToPEM(std::FILE& outputFile) const override;
+  void convertToPEMFile(std::FILE& outputFile) const override;
 
   [[nodiscard]] storvector_t convertToISCVector() const override;
 
@@ -401,7 +401,7 @@ void OpenSSLRSADNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, c
 #endif
 }
 
-void OpenSSLRSADNSCryptoKeyEngine::convertToPEM(std::FILE& outputFile) const
+void OpenSSLRSADNSCryptoKeyEngine::convertToPEMFile(std::FILE& outputFile) const
 {
 #if OPENSSL_VERSION_MAJOR >= 3
   if (PEM_write_PrivateKey(&outputFile, d_key.get(), nullptr, nullptr, 0, nullptr, nullptr) == 0) {
@@ -1025,7 +1025,7 @@ public:
    *
    * \exception std::runtime_error In case of OpenSSL errors.
    */
-  void convertToPEM(std::FILE& outputFile) const override;
+  void convertToPEMFile(std::FILE& outputFile) const override;
 
   [[nodiscard]] storvector_t convertToISCVector() const override;
   [[nodiscard]] std::string hash(const std::string& message) const override;
@@ -1198,7 +1198,7 @@ void OpenSSLECDSADNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc,
 #endif
 }
 
-void OpenSSLECDSADNSCryptoKeyEngine::convertToPEM(std::FILE& outputFile) const
+void OpenSSLECDSADNSCryptoKeyEngine::convertToPEMFile(std::FILE& outputFile) const
 {
 #if OPENSSL_VERSION_MAJOR >= 3
   if (PEM_write_PrivateKey(&outputFile, d_eckey.get(), nullptr, nullptr, 0, nullptr, nullptr) == 0) {
@@ -1780,7 +1780,7 @@ public:
    *
    * \exception std::runtime_error In case of OpenSSL errors.
    */
-  void convertToPEM(std::FILE& outputFile) const override;
+  void convertToPEMFile(std::FILE& outputFile) const override;
 
   [[nodiscard]] storvector_t convertToISCVector() const override;
   [[nodiscard]] std::string sign(const std::string& msg) const override;
@@ -1903,7 +1903,7 @@ void OpenSSLEDDSADNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc,
   }
 }
 
-void OpenSSLEDDSADNSCryptoKeyEngine::convertToPEM(std::FILE& outputFile) const
+void OpenSSLEDDSADNSCryptoKeyEngine::convertToPEMFile(std::FILE& outputFile) const
 {
   auto ret = PEM_write_PrivateKey(&outputFile, d_edkey.get(), nullptr, nullptr, 0, nullptr, nullptr);
   if (ret == 0) {
index b32052ea377bc5331c62e00b3359a220602ae051..4a95748d53d824dab8498711b7bd5884269c5d77 100644 (file)
@@ -3454,7 +3454,7 @@ try
     string zone = cmds.at(1);
     auto id = pdns::checked_stoi<unsigned int>(cmds.at(2));
     DNSSECPrivateKey dpk = dk.getKeyById(DNSName(zone), id);
-    dpk.getKey()->convertToPEM(*stdout);
+    dpk.getKey()->convertToPEMFile(*stdout);
   }
   else if (cmds.at(0) == "increase-serial") {
     if (cmds.size() < 2) {
index 5fbf1a3ed7bc0f9dd5393a69efefb8c5074c1226..3310c91fee84a02c986f7ed6b8b22724e9560e3f 100644 (file)
@@ -45,11 +45,11 @@ public:
    * Receives an open file handle and writes this key's contents to the
    * file.
    *
-   * \param[in] fp An open file handle for writing.
+   * \param[in] outputFile An open file handle for writing.
    *
    * \exception std::runtime_error In case of OpenSSL errors.
    */
-  void convertToPEM(std::FILE& fp) const override;
+  void convertToPEMFile(std::FILE& outputFile) const override;
 #endif
 
   [[nodiscard]] storvector_t convertToISCVector() const override;
@@ -106,14 +106,14 @@ void SodiumED25519DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc
   memcpy(d_seckey + secKeyLen, d_pubkey, pubKeyLen);
 }
 
-void SodiumED25519DNSCryptoKeyEngine::convertToPEM(std::FILE& fp) const
+void SodiumED25519DNSCryptoKeyEngine::convertToPEMFile(std::FILE& outputFile) const
 {
   auto key = std::unique_ptr<EVP_PKEY, void (*)(EVP_PKEY*)>(EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, nullptr, d_seckey, crypto_sign_ed25519_SEEDBYTES), EVP_PKEY_free);
   if (key == nullptr) {
     throw runtime_error(getName() + ": Could not create private key from buffer");
   }
 
-  auto ret = PEM_write_PrivateKey(&fp, key.get(), nullptr, nullptr, 0, nullptr, nullptr);
+  auto ret = PEM_write_PrivateKey(&outputFile, key.get(), nullptr, nullptr, 0, nullptr, nullptr);
   if (ret == 0) {
     throw runtime_error(getName() + ": Could not convert private key to PEM");
   }
index 062398522c812c25c3e2d1daf45d25ab7d581319..c870e787627f3ba26a59b0378addc699e5f37a73 100644 (file)
@@ -472,7 +472,7 @@ BOOST_FIXTURE_TEST_CASE(test_generic_signers, Fixture)
     std::string dckePEMOutput{};
     dckePEMOutput.resize(buflen);
     unique_ptr<std::FILE, decltype(&std::fclose)> dckePEMOutputFp{fmemopen(static_cast<void*>(dckePEMOutput.data()), dckePEMOutput.length() - 1, "w"), &std::fclose};
-    dcke->convertToPEM(*dckePEMOutputFp);
+    dcke->convertToPEMFile(*dckePEMOutputFp);
     std::fflush(dckePEMOutputFp.get());
     dckePEMOutput.resize(std::ftell(dckePEMOutputFp.get()));
 
@@ -481,7 +481,7 @@ BOOST_FIXTURE_TEST_CASE(test_generic_signers, Fixture)
     std::string pemKeyOutput{};
     pemKeyOutput.resize(buflen);
     unique_ptr<std::FILE, decltype(&std::fclose)> pemKeyOutputFp{fmemopen(static_cast<void*>(pemKeyOutput.data()), pemKeyOutput.length() - 1, "w"), &std::fclose};
-    pemKey->convertToPEM(*pemKeyOutputFp);
+    pemKey->convertToPEMFile(*pemKeyOutputFp);
     std::fflush(pemKeyOutputFp.get());
     pemKeyOutput.resize(std::ftell(pemKeyOutputFp.get()));