diff --git a/src/lib/crypto/botan_utils.hpp b/src/lib/crypto/botan_utils.hpp index cbb2f42e7..2877356e0 100644 --- a/src/lib/crypto/botan_utils.hpp +++ b/src/lib/crypto/botan_utils.hpp @@ -55,6 +55,8 @@ class bn { bn(const pgp::mpi &val) : bn(val.mpi, val.len){}; + bn(const &bn) = delete; + ~bn() { botan_mp_destroy(bn_); @@ -106,6 +108,9 @@ class Pubkey { public: Pubkey() : key_(NULL){}; + + Pubkey(const &Pubkey) = delete; + ~Pubkey() { botan_pubkey_destroy(key_); @@ -123,10 +128,14 @@ class Privkey { public: Privkey() : key_(NULL){}; + + Privkey(const &Privkey) = delete; + ~Privkey() { botan_privkey_destroy(key_); } + botan_privkey_t & get() noexcept { @@ -146,10 +155,14 @@ class Encrypt { public: Encrypt() : op_(NULL){}; + + Encrypt(const &Encrypt) = delete; + ~Encrypt() { botan_pk_op_encrypt_destroy(op_); } + botan_pk_op_encrypt_t & get() noexcept { @@ -162,10 +175,14 @@ class Decrypt { public: Decrypt() : op_(NULL){}; + + Decrypt(const &Decrypt) = delete; + ~Decrypt() { botan_pk_op_decrypt_destroy(op_); } + botan_pk_op_decrypt_t & get() noexcept { @@ -178,10 +195,14 @@ class Verify { public: Verify() : op_(NULL){}; + + Verify(const &Decrypt) = delete; + ~Verify() { botan_pk_op_verify_destroy(op_); } + botan_pk_op_verify_t & get() noexcept { @@ -194,10 +215,14 @@ class Sign { public: Sign() : op_(NULL){}; + + Sign(const &Sign) = delete; + ~Sign() { botan_pk_op_sign_destroy(op_); } + botan_pk_op_sign_t & get() noexcept { @@ -210,10 +235,14 @@ class KeyAgreement { public: KeyAgreement() : op_(NULL){}; + + KeyAgreement(const &KeyAgreement) = delete; + ~KeyAgreement() { botan_pk_op_key_agreement_destroy(op_); } + botan_pk_op_ka_t & get() noexcept { diff --git a/src/lib/crypto/ossl_utils.hpp b/src/lib/crypto/ossl_utils.hpp index 7667a6204..945ee0b4a 100644 --- a/src/lib/crypto/ossl_utils.hpp +++ b/src/lib/crypto/ossl_utils.hpp @@ -184,6 +184,8 @@ class BNCtx { } } + BNCtx(const BNCtx &) = delete; + ~BNCtx() { BN_CTX_free(ctx_); @@ -208,6 +210,8 @@ class BNRecpCtx { public: BNRecpCtx() : ctx_(BN_RECP_CTX_new()){}; + BNRecpCtx(const BNRecpCtx &) = delete; + ~BNRecpCtx() { BN_RECP_CTX_free(ctx_); @@ -226,6 +230,8 @@ class BNMontCtx { public: BNMontCtx() : ctx_(BN_MONT_CTX_new()){}; + BNMontCtx(const BNMontCtx &) = delete; + ~BNMontCtx() { BN_MONT_CTX_free(ctx_); @@ -381,6 +387,8 @@ class MDCtx { public: MDCtx() : ctx_(EVP_MD_CTX_new()){}; + MDCtx(const MDCtx &) = delete; + ~MDCtx() { EVP_MD_CTX_free(ctx_); @@ -409,6 +417,8 @@ class RSA { rsa_ = RSA_new(); } + RSA(const RSA &) = delete; + ~RSA() { RSA_free(rsa_); @@ -430,6 +440,8 @@ class DSA { dsa_ = DSA_new(); } + DSA(const DSA &) = delete; + ~DSA() { DSA_free(dsa_); @@ -455,6 +467,8 @@ class DH { { } + DH(const DH &) = delete; + ~DH() { DH_free(dh_); @@ -481,6 +495,8 @@ class ECKey { { } + ECKey(const ECKey &) = delete; + ~ECKey() { EC_KEY_free(key_); @@ -501,6 +517,8 @@ class ECPoint { { } + ECPoint(const ECPoint &) = delete; + ~ECPoint() { EC_POINT_free(pt_); @@ -554,6 +572,8 @@ class ParamBld { bld_ = OSSL_PARAM_BLD_new(); } + ParamBld(const ParamBld &) = delete; + ~ParamBld() { OSSL_PARAM_BLD_free(bld_);