aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2021-04-08 10:15:43 -0400
committerJack Lloyd <[email protected]>2021-04-08 10:15:43 -0400
commit7e5ad7e8d04737537f07ea00a306a9e245f7c802 (patch)
tree332ea62223be00414bc3b7478a40ccb9a0e61db5 /src/lib
parent185397786f0ba3179aaacc9039714b440b1841aa (diff)
parent77c9ac1b13f8000d4c5d60c17ff80136582b9098 (diff)
Merge GH #2704 Add PBKDF::new_object replacing clone
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pbkdf/pbkdf.h10
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.cpp4
-rw-r--r--src/lib/pbkdf/pbkdf2/pbkdf2.h2
-rw-r--r--src/lib/pbkdf/pgp_s2k/pgp_s2k.h4
4 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/pbkdf/pbkdf.h b/src/lib/pbkdf/pbkdf.h
index e7f0a84ee..67180f244 100644
--- a/src/lib/pbkdf/pbkdf.h
+++ b/src/lib/pbkdf/pbkdf.h
@@ -51,7 +51,15 @@ class BOTAN_PUBLIC_API(2,0) PBKDF
/**
* @return new instance of this same algorithm
*/
- virtual PBKDF* clone() const = 0;
+ virtual std::unique_ptr<PBKDF> new_object() const = 0;
+
+ /**
+ * @return new instance of this same algorithm
+ */
+ PBKDF* clone() const
+ {
+ return this->new_object().release();
+ }
/**
* @return name of this PBKDF
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
index 51dfa2fdd..68e1ae45b 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp
@@ -174,9 +174,9 @@ std::string PKCS5_PBKDF2::name() const
return "PBKDF2(" + m_mac->name() + ")";
}
-PBKDF* PKCS5_PBKDF2::clone() const
+std::unique_ptr<PBKDF> PKCS5_PBKDF2::new_object() const
{
- return new PKCS5_PBKDF2(m_mac->clone());
+ return std::make_unique<PKCS5_PBKDF2>(m_mac->clone());
}
// PasswordHash interface
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.h b/src/lib/pbkdf/pbkdf2/pbkdf2.h
index bea5893f3..e1d3e6f0d 100644
--- a/src/lib/pbkdf/pbkdf2/pbkdf2.h
+++ b/src/lib/pbkdf/pbkdf2/pbkdf2.h
@@ -95,7 +95,7 @@ class BOTAN_PUBLIC_API(2,0) PKCS5_PBKDF2 final : public PBKDF
public:
std::string name() const override;
- PBKDF* clone() const override;
+ std::unique_ptr<PBKDF> new_object() const override;
size_t pbkdf(uint8_t output_buf[], size_t output_len,
const std::string& passphrase,
diff --git a/src/lib/pbkdf/pgp_s2k/pgp_s2k.h b/src/lib/pbkdf/pgp_s2k/pgp_s2k.h
index 8d148e725..db70fa141 100644
--- a/src/lib/pbkdf/pgp_s2k/pgp_s2k.h
+++ b/src/lib/pbkdf/pgp_s2k/pgp_s2k.h
@@ -72,9 +72,9 @@ class BOTAN_PUBLIC_API(2,2) OpenPGP_S2K final : public PBKDF
return "OpenPGP-S2K(" + m_hash->name() + ")";
}
- PBKDF* clone() const override
+ std::unique_ptr<PBKDF> new_object() const override
{
- return new OpenPGP_S2K(m_hash->clone());
+ return std::make_unique<OpenPGP_S2K>(m_hash->clone());
}
size_t pbkdf(uint8_t output_buf[], size_t output_len,