From: Fred Morcos Date: Thu, 9 Feb 2023 16:34:03 +0000 (+0100) Subject: Rename (and cleanup) convertToPEM to convertToPEMFile X-Git-Tag: dnsdist-1.8.0-rc1~18^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8b5e8ba4cbd72a6b6a84342fb752d777b977b49;p=thirdparty%2Fpdns.git Rename (and cleanup) convertToPEM to convertToPEMFile --- diff --git a/pdns/decafsigners.cc b/pdns/decafsigners.cc index 09e25aa7eb..c1fc72663a 100644 --- a/pdns/decafsigners.cc +++ b/pdns/decafsigners.cc @@ -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_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_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"); } diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index bcba403f4d..6ef5dac6e2 100644 --- a/pdns/dnssecinfra.hh +++ b/pdns/dnssecinfra.hh @@ -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"); }; diff --git a/pdns/opensslsigners.cc b/pdns/opensslsigners.cc index 94b96ff3e7..5c26c747fc 100644 --- a/pdns/opensslsigners.cc +++ b/pdns/opensslsigners.cc @@ -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) { diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index b32052ea37..4a95748d53 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -3454,7 +3454,7 @@ try string zone = cmds.at(1); auto id = pdns::checked_stoi(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) { diff --git a/pdns/sodiumsigners.cc b/pdns/sodiumsigners.cc index 5fbf1a3ed7..3310c91fee 100644 --- a/pdns/sodiumsigners.cc +++ b/pdns/sodiumsigners.cc @@ -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_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"); } diff --git a/pdns/test-signers.cc b/pdns/test-signers.cc index 062398522c..c870e78762 100644 --- a/pdns/test-signers.cc +++ b/pdns/test-signers.cc @@ -472,7 +472,7 @@ BOOST_FIXTURE_TEST_CASE(test_generic_signers, Fixture) std::string dckePEMOutput{}; dckePEMOutput.resize(buflen); unique_ptr dckePEMOutputFp{fmemopen(static_cast(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 pemKeyOutputFp{fmemopen(static_cast(pemKeyOutput.data()), pemKeyOutput.length() - 1, "w"), &std::fclose}; - pemKey->convertToPEM(*pemKeyOutputFp); + pemKey->convertToPEMFile(*pemKeyOutputFp); std::fflush(pemKeyOutputFp.get()); pemKeyOutput.resize(std::ftell(pemKeyOutputFp.get()));