diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/ca.cpp | 2 | ||||
-rw-r--r-- | src/cmd/dsa_sign.cpp | 2 | ||||
-rw-r--r-- | src/cmd/dsa_ver.cpp | 2 | ||||
-rw-r--r-- | src/cmd/keygen.cpp | 2 | ||||
-rw-r--r-- | src/lib/cert/x509/certstor.cpp | 5 | ||||
-rw-r--r-- | src/lib/cert/x509/certstor.h | 2 | ||||
-rw-r--r-- | src/tests/test_pubkey.cpp | 4 | ||||
-rw-r--r-- | src/tests/unit_tls.cpp | 22 |
8 files changed, 25 insertions, 16 deletions
diff --git a/src/cmd/ca.cpp b/src/cmd/ca.cpp index fd1873cc3..b32f07f51 100644 --- a/src/cmd/ca.cpp +++ b/src/cmd/ca.cpp @@ -33,7 +33,7 @@ int ca(int argc, char* argv[]) X509_Certificate ca_cert(arg_ca_cert); - std::auto_ptr<PKCS8_PrivateKey> privkey( + std::unique_ptr<PKCS8_PrivateKey> privkey( PKCS8::load_key(arg_ca_key, rng, arg_passphrase) ); diff --git a/src/cmd/dsa_sign.cpp b/src/cmd/dsa_sign.cpp index c052b8a73..baf884301 100644 --- a/src/cmd/dsa_sign.cpp +++ b/src/cmd/dsa_sign.cpp @@ -49,7 +49,7 @@ int dsa_sign(int argc, char* argv[]) AutoSeeded_RNG rng; - std::auto_ptr<PKCS8_PrivateKey> key( + std::unique_ptr<PKCS8_PrivateKey> key( PKCS8::load_key(argv[1], rng, passphrase) ); diff --git a/src/cmd/dsa_ver.cpp b/src/cmd/dsa_ver.cpp index 1d058df14..0490bb065 100644 --- a/src/cmd/dsa_ver.cpp +++ b/src/cmd/dsa_ver.cpp @@ -45,7 +45,7 @@ int dsa_verify(int argc, char* argv[]) std::string sigstr; getline(sigfile, sigstr); - std::auto_ptr<X509_PublicKey> key(X509::load_key(argv[1])); + std::unique_ptr<X509_PublicKey> key(X509::load_key(argv[1])); DSA_PublicKey* dsakey = dynamic_cast<DSA_PublicKey*>(key.get()); if(!dsakey) diff --git a/src/cmd/keygen.cpp b/src/cmd/keygen.cpp index 9a9d17322..99769a62f 100644 --- a/src/cmd/keygen.cpp +++ b/src/cmd/keygen.cpp @@ -97,7 +97,7 @@ int keygen(int argc, char* argv[]) AutoSeeded_RNG rng; - std::auto_ptr<Private_Key> key(gen_key(rng, algo, bits)); + std::unique_ptr<Private_Key> key(gen_key(rng, algo, bits)); pub << X509::PEM_encode(*key); diff --git a/src/lib/cert/x509/certstor.cpp b/src/lib/cert/x509/certstor.cpp index d7e6f0a65..d075fe706 100644 --- a/src/lib/cert/x509/certstor.cpp +++ b/src/lib/cert/x509/certstor.cpp @@ -108,6 +108,11 @@ const X509_CRL* Certificate_Store_In_Memory::find_crl_for(const X509_Certificate return nullptr; } +Certificate_Store_In_Memory::Certificate_Store_In_Memory(const X509_Certificate& cert) + { + add_certificate(cert); + } + Certificate_Store_In_Memory::Certificate_Store_In_Memory(const std::string& dir) { if(dir == "") diff --git a/src/lib/cert/x509/certstor.h b/src/lib/cert/x509/certstor.h index 6d6de2e7a..eb42c6a49 100644 --- a/src/lib/cert/x509/certstor.h +++ b/src/lib/cert/x509/certstor.h @@ -50,6 +50,8 @@ class BOTAN_DLL Certificate_Store_In_Memory : public Certificate_Store */ Certificate_Store_In_Memory(const std::string& dir); + Certificate_Store_In_Memory(const X509_Certificate& cert); + Certificate_Store_In_Memory() {} void add_certificate(const X509_Certificate& cert); diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index 9f46e5398..a05760fd2 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -93,7 +93,7 @@ size_t validate_save_and_load(const Private_Key* priv_key, try { DataSource_Memory input_pub(pub_pem); - std::auto_ptr<Public_Key> restored_pub(X509::load_key(input_pub)); + std::unique_ptr<Public_Key> restored_pub(X509::load_key(input_pub)); if(!restored_pub.get()) { @@ -119,7 +119,7 @@ size_t validate_save_and_load(const Private_Key* priv_key, try { DataSource_Memory input_priv(priv_pem); - std::auto_ptr<Private_Key> restored_priv( + std::unique_ptr<Private_Key> restored_priv( PKCS8::load_key(input_priv, rng)); if(!restored_priv.get()) diff --git a/src/tests/unit_tls.cpp b/src/tests/unit_tls.cpp index 60b7297a1..aeab7cd4e 100644 --- a/src/tests/unit_tls.cpp +++ b/src/tests/unit_tls.cpp @@ -35,16 +35,18 @@ class Credentials_Manager_Test : public Botan::Credentials_Manager m_ca_cert(ca_cert), m_key(server_key) { - auto store = new Certificate_Store_In_Memory; - store->add_certificate(m_ca_cert); - m_stores.push_back(store); + std::unique_ptr<Certificate_Store> store(new Certificate_Store_In_Memory(m_ca_cert)); + m_stores.push_back(std::move(store)); } std::vector<Certificate_Store*> trusted_certificate_authorities(const std::string&, const std::string&) override { - return m_stores; + std::vector<Certificate_Store*> v; + for(auto&& store : m_stores) + v.push_back(store.get()); + return v; } std::vector<X509_Certificate> cert_chain( @@ -92,17 +94,17 @@ class Credentials_Manager_Test : public Botan::Credentials_Manager const std::string&, const std::string&) override { - return m_key; + return m_key.get(); } public: X509_Certificate m_server_cert, m_ca_cert; - Private_Key* m_key; - std::vector<Certificate_Store*> m_stores; + std::unique_ptr<Private_Key> m_key; + std::vector<std::unique_ptr<Certificate_Store>> m_stores; }; Credentials_Manager* create_creds(RandomNumberGenerator& rng) { - std::auto_ptr<Private_Key> ca_key(new RSA_PrivateKey(rng, 1024)); + std::unique_ptr<Private_Key> ca_key(new RSA_PrivateKey(rng, 1024)); X509_Cert_Options ca_opts; ca_opts.common_name = "Test CA"; @@ -288,13 +290,13 @@ size_t test_tls() Test_Policy default_policy; auto& rng = test_rng(); - std::auto_ptr<Credentials_Manager> basic_creds(create_creds(rng)); + std::unique_ptr<Credentials_Manager> basic_creds(create_creds(rng)); errors += basic_test_handshake(rng, TLS::Protocol_Version::TLS_V10, *basic_creds, default_policy); errors += basic_test_handshake(rng, TLS::Protocol_Version::TLS_V11, *basic_creds, default_policy); errors += basic_test_handshake(rng, TLS::Protocol_Version::TLS_V12, *basic_creds, default_policy); - test_report("TLS", 4, errors); + test_report("TLS", 3, errors); return errors; } |