]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 9 Feb 2023 16:16:08 +0000 (17:16 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Tue, 14 Feb 2023 09:09:12 +0000 (10:09 +0100)
pdns/decafsigners.cc
pdns/dnssecinfra.cc
pdns/dnssecinfra.hh
pdns/sodiumsigners.cc

index fb57ccd9a59243ca7a721482def34a0177304dbb..09e25aa7ebafa99b8ac2f8d2b3ed9a9b958024cb 100644 (file)
@@ -34,13 +34,13 @@ public:
    * \param[in] filename Only used for providing filename information in
    * error messages.
    *
-   * \param[in] fp An open file handle to a file containing ED25519 PEM
+   * \param[in] inputFile An open file handle to a file containing ED25519 PEM
    * contents.
    *
    * \return An ED25519 key engine populated with the contents of the
    * PEM file.
    */
-  void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& fp) override;
+  void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile) override;
 
   /**
    * \brief Writes this key's contents to a file.
@@ -55,11 +55,11 @@ public:
   void convertToPEM(std::FILE& fp) const override;
 #endif
 
-  storvector_t convertToISCVector() const override;
-  std::string sign(const std::string& msg) const override;
-  bool verify(const std::string& msg, const std::string& signature) const override;
-  std::string getPublicKeyString() const override;
-  int getBits() const override;
+  [[nodiscard]] storvector_t convertToISCVector() const override;
+  [[nodiscard]] std::string sign(const std::string& msg) const override;
+  [[nodiscard]] bool verify(const std::string& msg, const std::string& signature) const override;
+  [[nodiscard]] std::string getPublicKeyString() const override;
+  [[nodiscard]] int getBits() const override;
   void fromISCMap(DNSKEYRecordContent& drc, std::map<std::string, std::string>& stormap) override;
   void fromPublicKeyString(const std::string& content) override;
 
@@ -89,10 +89,10 @@ void DecafED25519DNSCryptoKeyEngine::create(unsigned int bits)
 }
 
 #if defined(HAVE_LIBCRYPTO_ED25519)
-void DecafED25519DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, const string& filename, std::FILE& fp)
+void DecafED25519DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, const string& filename, std::FILE& inputFile)
 {
   drc.d_algorithm = d_algorithm;
-  auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(PEM_read_PrivateKey(&fp, nullptr, nullptr, nullptr), &EVP_PKEY_free);
+  auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(PEM_read_PrivateKey(&inputFile, nullptr, nullptr, nullptr), &EVP_PKEY_free);
   if (key == nullptr) {
     throw runtime_error(getName() + ": Failed to read private key from PEM file `" + filename + "`");
   }
@@ -232,13 +232,13 @@ public:
    * \param[in] filename Only used for providing filename information in
    * error messages.
    *
-   * \param[in] fp An open file handle to a file containing ED448 PEM
+   * \param[in] inputFile An open file handle to a file containing ED448 PEM
    * contents.
    *
    * \return An ED448 key engine populated with the contents of the PEM
    * file.
    */
-  void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& fp) override;
+  void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile) override;
 
   /**
    * \brief Writes this key's contents to a file.
@@ -287,10 +287,10 @@ void DecafED448DNSCryptoKeyEngine::create(unsigned int bits)
 }
 
 #if defined(HAVE_LIBCRYPTO_ED448)
-void DecafED448DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, const string& filename, std::FILE& fp)
+void DecafED448DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, const string& filename, std::FILE& inputFile)
 {
   drc.d_algorithm = d_algorithm;
-  auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(PEM_read_PrivateKey(&fp, nullptr, nullptr, nullptr), &EVP_PKEY_free);
+  auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(PEM_read_PrivateKey(&inputFile, nullptr, nullptr, nullptr), &EVP_PKEY_free);
   if (key == nullptr) {
     throw runtime_error(getName() + ": Failed to read private key from PEM file `" + filename + "`");
   }
index d379257706feab543d9adb4e9cbceb223c4775d8..af32304e7d314bf5ead46afbce5a57c0777a32d3 100644 (file)
@@ -170,10 +170,10 @@ std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromISCString(DNSKEY
   return dpk;
 }
 
-std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& fp, const uint8_t algorithm)
+std::unique_ptr<DNSCryptoKeyEngine> DNSCryptoKeyEngine::makeFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile, const uint8_t algorithm)
 {
   auto maker = DNSCryptoKeyEngine::make(algorithm);
-  maker->createFromPEMFile(drc, filename, fp);
+  maker->createFromPEMFile(drc, filename, inputFile);
   return maker;
 }
 
index 61d718341c947ada6b9034aa859f6d51f52c2498..bcba403f4d55fc5ed794c0337c82377b173cba83 100644 (file)
@@ -43,7 +43,7 @@ class DNSCryptoKeyEngine
     using storvector_t = std::vector<std::pair<std::string, std::string>>;
     virtual void create(unsigned int bits)=0;
 
-    virtual void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& fp)
+    virtual void createFromPEMFile(DNSKEYRecordContent& /* drc */, const std::string& /* filename */, std::FILE& /* inputFile */)
     {
       throw std::runtime_error("Can't create key from PEM file");
     }
index 7b0768349e1f721474b082d6d6aa3e571d823bd5..5fbf1a3ed7bc0f9dd5393a69efefb8c5074c1226 100644 (file)
@@ -31,13 +31,13 @@ public:
    * \param[in] filename Only used for providing filename information in
    * error messages.
    *
-   * \param[in] fp An open file handle to a file containing ED25519 PEM
+   * \param[in] inputFile An open file handle to a file containing ED25519 PEM
    * contents.
    *
    * \return An ED25519 key engine populated with the contents of the
    * PEM file.
    */
-  void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& fp) override;
+  void createFromPEMFile(DNSKEYRecordContent& drc, const std::string& filename, std::FILE& inputFile) override;
 
   /**
    * \brief Writes this key's contents to a file.
@@ -52,11 +52,11 @@ public:
   void convertToPEM(std::FILE& fp) const override;
 #endif
 
-  storvector_t convertToISCVector() const override;
-  std::string sign(const std::string& msg) const override;
-  bool verify(const std::string& msg, const std::string& signature) const override;
-  std::string getPublicKeyString() const override;
-  int getBits() const override;
+  [[nodiscard]] storvector_t convertToISCVector() const override;
+  [[nodiscard]] std::string sign(const std::string& msg) const override;
+  [[nodiscard]] bool verify(const std::string& msg, const std::string& signature) const override;
+  [[nodiscard]] std::string getPublicKeyString() const override;
+  [[nodiscard]] int getBits() const override;
   void fromISCMap(DNSKEYRecordContent& drc, std::map<std::string, std::string>& stormap) override;
   void fromPublicKeyString(const std::string& content) override;
 
@@ -79,10 +79,10 @@ void SodiumED25519DNSCryptoKeyEngine::create(unsigned int bits)
 }
 
 #if defined(HAVE_LIBCRYPTO_ED25519)
-void SodiumED25519DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, const string& filename, std::FILE& fp)
+void SodiumED25519DNSCryptoKeyEngine::createFromPEMFile(DNSKEYRecordContent& drc, const string& filename, std::FILE& inputFile)
 {
   drc.d_algorithm = d_algorithm;
-  auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(PEM_read_PrivateKey(&fp, nullptr, nullptr, nullptr), &EVP_PKEY_free);
+  auto key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>(PEM_read_PrivateKey(&inputFile, nullptr, nullptr, nullptr), &EVP_PKEY_free);
   if (key == nullptr) {
     throw runtime_error(getName() + ": Failed to read private key from PEM file `" + filename + "`");
   }