]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix the confusing argument ordering of makeFromPEMFile
authorFred Morcos <fred.morcos@open-xchange.com>
Fri, 10 Feb 2023 14:29:23 +0000 (15:29 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Tue, 14 Feb 2023 09:09:13 +0000 (10:09 +0100)
pdns/dnssecinfra.cc
pdns/dnssecinfra.hh
pdns/pdnsutil.cc
pdns/test-signers.cc

index af32304e7d314bf5ead46afbce5a57c0777a32d3..10ba1442a71a9d9c0dfda5e5cadd8ac0b0000c2b 100644 (file)
@@ -170,7 +170,7 @@ std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromISCString(DNSKEY
   return dpk;
 }
 
-std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile, const uint8_t algorithm)
+std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromPEMFile(DNSKEYRecordContent& drc, const uint8_t algorithm, std::FILE& inputFile, const std::string& filename)
 {
   auto maker = DNSCryptoKeyEngine::make(algorithm);
   maker->createFromPEMFile(drc, filename, inputFile);
index 6ef5dac6e2e8b6daa0ab2d7ebbeb8c5508e6553f..d3a437d5bb2c989b2b7b98d52bd6ecff2bb3f4e1 100644 (file)
@@ -86,24 +86,22 @@ class DNSCryptoKeyEngine
     /**
      * \brief Creates a key engine from a PEM file.
      *
-     * Receives an open file handle with PEM contents and creates a key
-     * engine corresponding to the algorithm requested.
+     * Receives an open file handle with PEM contents and creates a key engine
+     * corresponding to the algorithm requested.
      *
      * \param[in] drc Key record contents to be populated.
      *
-     * \param[in] filename Only used for providing filename information
-     * in error messages.
-     *
-     * \param[in] fp An open file handle to a file containing PEM
-     * contents.
-     *
      * \param[in] algorithm Which algorithm to use. See
      * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
      *
-     * \return A key engine corresponding to the requested algorithm and
-     * populated with the contents of the PEM file.
+     * \param[in] fp An open file handle to a file containing PEM contents.
+     *
+     * \param[in] filename Only used for providing filename information in error messages.
+     *
+     * \return A key engine corresponding to the requested algorithm and populated with
+     * the contents of the PEM file.
      */
-    static std::unique_ptr<DNSCryptoKeyEngine> makeFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile, uint8_t algorithm);
+    static std::unique_ptr<DNSCryptoKeyEngine> makeFromPEMFile(DNSKEYRecordContent& drc, uint8_t algorithm, std::FILE& inputFile, const std::string& filename);
 
     static std::unique_ptr<DNSCryptoKeyEngine> makeFromISCString(DNSKEYRecordContent& drc, const std::string& content);
     static std::unique_ptr<DNSCryptoKeyEngine> makeFromPublicKeyString(unsigned int algorithm, const std::string& raw);
index 4a95748d53d824dab8498711b7bd5884269c5d77..00cee06576b6ee9beae9e4d50cc622a06dcad0e2 100644 (file)
@@ -3481,7 +3481,7 @@ try
     }
 
     DNSKEYRecordContent drc;
-    shared_ptr<DNSCryptoKeyEngine> key{DNSCryptoKeyEngine::makeFromPEMFile(drc, filename, *fp, algorithm)};
+    shared_ptr<DNSCryptoKeyEngine> key{DNSCryptoKeyEngine::makeFromPEMFile(drc, algorithm, *fp, filename)};
     if (!key) {
       cerr << "Could not convert key from PEM to internal format" << endl;
       return 1;
index fa974679a88f6da23ff4ac0bc936ecf31155681f..1c9b46142456ae3b8aab6eb65971eba8ecf847a8 100644 (file)
@@ -463,7 +463,7 @@ BOOST_FIXTURE_TEST_CASE(test_generic_signers, Fixture)
     BOOST_REQUIRE(inputFile.get() != nullptr);
 
     DNSKEYRecordContent pemDRC;
-    shared_ptr<DNSCryptoKeyEngine> pemKey{DNSCryptoKeyEngine::makeFromPEMFile(pemDRC, "<buffer>", *inputFile, signer.algorithm)};
+    shared_ptr<DNSCryptoKeyEngine> pemKey{DNSCryptoKeyEngine::makeFromPEMFile(pemDRC, signer.algorithm, *inputFile, "<buffer>")};
 
     BOOST_CHECK_EQUAL(pemKey->convertToISC(), dcke->convertToISC());