diff options
author | lloyd <[email protected]> | 2012-05-18 20:44:34 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-05-18 20:44:34 +0000 |
commit | 8383b0b503c812e45f2780217b048a19a8946853 (patch) | |
tree | 939403bad80ee2b1e13b69c82adc316422a9c7d6 | |
parent | c691561f3198f481c13457433efbccc1c9fcd898 (diff) |
Replace 0 and NULL pointer constants with nullptr. Also fix an old
style cast in secmem.h
67 files changed, 200 insertions, 195 deletions
diff --git a/checks/dolook.cpp b/checks/dolook.cpp index 20e260f64..364a3f8c3 100644 --- a/checks/dolook.cpp +++ b/checks/dolook.cpp @@ -139,7 +139,7 @@ class KDF_Filter : public Filter Filter* lookup_pbkdf(const std::string& algname, const std::vector<std::string>& params) { - PBKDF* pbkdf = 0; + PBKDF* pbkdf = nullptr; try { pbkdf = get_pbkdf(algname); @@ -149,7 +149,7 @@ Filter* lookup_pbkdf(const std::string& algname, if(pbkdf) return new PBKDF_Filter(pbkdf, params[0], to_u32bit(params[1]), to_u32bit(params[2])); - return 0; + return nullptr; } void RNG_Filter::write(const byte[], size_t length) @@ -163,7 +163,7 @@ void RNG_Filter::write(const byte[], size_t length) Filter* lookup_rng(const std::string& algname, const std::string& key) { - RandomNumberGenerator* prng = 0; + RandomNumberGenerator* prng = nullptr; #if defined(BOTAN_HAS_AUTO_SEEDING_RNG) if(algname == "AutoSeeded") @@ -233,21 +233,21 @@ Filter* lookup_rng(const std::string& algname, return new RNG_Filter(prng); } - return 0; + return nullptr; } Filter* lookup_kdf(const std::string& algname, const std::string& salt, const std::string& params) { - KDF* kdf = 0; + KDF* kdf = nullptr; try { kdf = get_kdf(algname); } - catch(...) { return 0; } + catch(...) { return nullptr; } if(kdf) return new KDF_Filter(kdf, salt, to_u32bit(params)); - return 0; + return nullptr; } Filter* lookup_encoder(const std::string& algname) @@ -278,7 +278,7 @@ Filter* lookup_encoder(const std::string& algname) return new Zlib_Decompression; #endif - return 0; + return nullptr; } } @@ -288,7 +288,7 @@ Filter* lookup(const std::string& algname, { std::string key = params[0]; std::string iv = params[1]; - Filter* filter = 0; + Filter* filter = nullptr; // The order of the lookup has to change based on how the names are // formatted and parsed. @@ -304,6 +304,6 @@ Filter* lookup(const std::string& algname, filter = lookup_pbkdf(algname, params); if(filter) return filter; - return 0; + return nullptr; } diff --git a/checks/pk.cpp b/checks/pk.cpp index 261c5f78c..5ef5df94b 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -108,7 +108,7 @@ void validate_save_and_load(const Private_Key* priv_key, DataSource_Memory input_pub(pub_pem); std::auto_ptr<Public_Key> restored_pub(X509::load_key(input_pub)); - if(restored_pub.get() == 0) + if(!restored_pub.get()) std::cout << "Could not recover " << name << " public key\n"; else if(restored_pub->check_key(rng, true) == false) std::cout << "Restored pubkey failed self tests " << name << "\n"; @@ -128,7 +128,7 @@ void validate_save_and_load(const Private_Key* priv_key, std::auto_ptr<Private_Key> restored_priv( PKCS8::load_key(input_priv, rng)); - if(restored_priv.get() == 0) + if(!restored_priv.get()) std::cout << "Could not recover " << name << " privlic key\n"; else if(restored_priv->check_key(rng, true) == false) std::cout << "Restored privkey failed self tests " << name << "\n"; diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp index 8241ee5d1..da2221b90 100644 --- a/checks/pk_bench.cpp +++ b/checks/pk_bench.cpp @@ -83,7 +83,7 @@ const char* ec_domains[] = { "secp256r1", "secp384r1", "secp521r1", - 0 + nullptr }; class Benchmark_Report @@ -462,7 +462,7 @@ void benchmark_dsa_nr(RandomNumberGenerator& rng, const char* domains[] = { "dsa/jce/1024", "dsa/botan/2048", "dsa/botan/3072", - NULL }; + nullptr }; std::string algo_name; @@ -513,7 +513,7 @@ void benchmark_dh(RandomNumberGenerator& rng, "modp/ietf/4096", "modp/ietf/6144", "modp/ietf/8192", - NULL }; + nullptr }; for(size_t j = 0; domains[j]; j++) { @@ -574,7 +574,7 @@ void benchmark_dlies(RandomNumberGenerator& rng, "modp/ietf/4096", "modp/ietf/6144", "modp/ietf/8192", - NULL }; + nullptr }; for(size_t j = 0; domains[j]; j++) { @@ -633,7 +633,7 @@ void benchmark_elg(RandomNumberGenerator& rng, "modp/ietf/4096", "modp/ietf/6144", "modp/ietf/8192", - NULL }; + nullptr }; const std::string algo_name = "ElGamal"; diff --git a/checks/validate.cpp b/checks/validate.cpp index c6a4a29d0..bae5e857f 100644 --- a/checks/validate.cpp +++ b/checks/validate.cpp @@ -474,8 +474,10 @@ bool failed_test(const std::string& algo, try { Botan::Filter* test = lookup(algo, params); - if(test == 0 && is_extension) return !exp_pass; - if(test == 0) + + if(!test && is_extension) return !exp_pass; + + if(!test) { if(algo != last_missing) { diff --git a/src/algo_factory/algo_cache.h b/src/algo_factory/algo_cache.h index 3a792c994..11a5580fb 100644 --- a/src/algo_factory/algo_cache.h +++ b/src/algo_factory/algo_cache.h @@ -112,7 +112,7 @@ const T* Algorithm_Cache<T>::get(const std::string& algo_spec, auto algo = find_algorithm(algo_spec); if(algo == algorithms.end()) // algo not found at all (no providers) - return 0; + return nullptr; // If a provider is requested specifically, return it or fail entirely if(requested_provider != "") @@ -120,10 +120,10 @@ const T* Algorithm_Cache<T>::get(const std::string& algo_spec, auto prov = algo->second.find(requested_provider); if(prov != algo->second.end()) return prov->second; - return 0; + return nullptr; } - const T* prototype = 0; + const T* prototype = nullptr; std::string prototype_provider; size_t prototype_prov_weight = 0; diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index 9e4f78569..1683648bd 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -30,7 +30,7 @@ template<typename T> T* engine_get_algo(Engine*, const SCAN_Name&, Algorithm_Factory&) - { return 0; } + { return nullptr; } template<> BlockCipher* engine_get_algo(Engine* engine, @@ -75,7 +75,7 @@ const T* factory_prototype(const std::string& algo_spec, SCAN_Name scan_name(algo_spec); if(scan_name.cipher_mode() != "") - return 0; + return nullptr; for(size_t i = 0; i != engines.size(); ++i) { @@ -157,7 +157,7 @@ void Algorithm_Factory::set_preferred_provider(const std::string& algo_spec, Engine* Algorithm_Factory::get_engine_n(size_t n) const { if(n >= engines.size()) - return 0; + return nullptr; return engines[n]; } diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h index 7c27c8d3b..5ee374b6d 100644 --- a/src/alloc/secmem.h +++ b/src/alloc/secmem.h @@ -61,9 +61,10 @@ class secure_allocator } template<typename U, typename... Args> - void - construct(U* p, Args&&... args) - { ::new((void *)p) U(std::forward<Args>(args)...); } + void construct(U* p, Args&&... args) + { + ::new(static_cast<void*>(p)) U(std::forward<Args>(args)...); + } template<typename U> void destroy(U* p) { p->~U(); } diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp index ea0a380d4..dbd59988b 100644 --- a/src/asn1/ber_dec.cpp +++ b/src/asn1/ber_dec.cpp @@ -276,7 +276,7 @@ BER_Decoder::BER_Decoder(DataSource& src) source = &src; owns = false; pushed.type_tag = pushed.class_tag = NO_OBJECT; - parent = 0; + parent = nullptr; } /* @@ -287,7 +287,7 @@ BER_Decoder::BER_Decoder(const byte data[], size_t length) source = new DataSource_Memory(data, length); owns = true; pushed.type_tag = pushed.class_tag = NO_OBJECT; - parent = 0; + parent = nullptr; } /* @@ -298,7 +298,7 @@ BER_Decoder::BER_Decoder(const secure_vector<byte>& data) source = new DataSource_Memory(data); owns = true; pushed.type_tag = pushed.class_tag = NO_OBJECT; - parent = 0; + parent = nullptr; } /* @@ -309,7 +309,7 @@ BER_Decoder::BER_Decoder(const std::vector<byte>& data) source = new DataSource_Memory(&data[0], data.size()); owns = true; pushed.type_tag = pushed.class_tag = NO_OBJECT; - parent = 0; + parent = nullptr; } /* @@ -335,7 +335,7 @@ BER_Decoder::~BER_Decoder() { if(owns) delete source; - source = 0; + source = nullptr; } /* diff --git a/src/asn1/der_enc.cpp b/src/asn1/der_enc.cpp index ea9dfe9f8..594c32539 100644 --- a/src/asn1/der_enc.cpp +++ b/src/asn1/der_enc.cpp @@ -205,7 +205,7 @@ DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], size_t length) */ DER_Encoder& DER_Encoder::encode_null() { - return add_object(NULL_TAG, UNIVERSAL, 0, 0); + return add_object(NULL_TAG, UNIVERSAL, nullptr, 0); } /* diff --git a/src/block/aes_ssse3/aes_ssse3.cpp b/src/block/aes_ssse3/aes_ssse3.cpp index 774ccbabb..a9ab29863 100644 --- a/src/block/aes_ssse3/aes_ssse3.cpp +++ b/src/block/aes_ssse3/aes_ssse3.cpp @@ -568,7 +568,7 @@ void AES_256_SSSE3::key_schedule(const byte keyb[], size_t) _mm_storeu_si128(EK_mm + i, aes_schedule_mangle(key2, i % 4)); _mm_storeu_si128(DK_mm + (14-i), aes_schedule_mangle_dec(key2, (i+2) % 4)); - key2 = aes_schedule_round(NULL, _mm_shuffle_epi32(key2, 0xFF), k_t); + key2 = aes_schedule_round(nullptr, _mm_shuffle_epi32(key2, 0xFF), k_t); _mm_storeu_si128(EK_mm + i + 1, aes_schedule_mangle(key2, (i - 1) % 4)); _mm_storeu_si128(DK_mm + (13-i), aes_schedule_mangle_dec(key2, (i+1) % 4)); } diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt index f3babb394..ccbba33fa 100644 --- a/src/build-data/cc/gcc.txt +++ b/src/build-data/cc/gcc.txt @@ -11,7 +11,7 @@ add_lib_option -l lang_flags "-D_REENTRANT -std=c++0x" warning_flags "-W -Wall" -maintainer_warning_flags "-Werror -Wall -Wextra -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wold-style-cast" +maintainer_warning_flags "-Werror -Wall -Wextra -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wold-style-cast -Wzero-as-null-pointer-constant" lib_opt_flags "-O3" check_opt_flags "-O2" diff --git a/src/cert/x509cert/x509_ext.cpp b/src/cert/x509cert/x509_ext.cpp index 873de4264..919fb790a 100644 --- a/src/cert/x509cert/x509_ext.cpp +++ b/src/cert/x509cert/x509_ext.cpp @@ -36,7 +36,7 @@ Certificate_Extension* Extensions::get_extension(const OID& oid) X509_EXTENSION("X509v3.CertificatePolicies", Certificate_Policies); X509_EXTENSION("X509v3.ReasonCode", CRL_ReasonCode); - return 0; + return nullptr; } /* diff --git a/src/cert/x509cert/x509cert.cpp b/src/cert/x509cert/x509cert.cpp index 8dc4b8b0c..95033f75e 100644 --- a/src/cert/x509cert/x509cert.cpp +++ b/src/cert/x509cert/x509cert.cpp @@ -385,7 +385,7 @@ std::string X509_Certificate::to_string() const "DNS", "URI", "PKIX.XMPPAddr", - 0 }; + nullptr }; std::ostringstream out; diff --git a/src/codec/openpgp/openpgp.cpp b/src/codec/openpgp/openpgp.cpp index fe6ac6edf..7bd811a2f 100644 --- a/src/codec/openpgp/openpgp.cpp +++ b/src/codec/openpgp/openpgp.cpp @@ -136,7 +136,7 @@ secure_vector<byte> PGP_decode(DataSource& source, } Pipe base64(new Base64_Decoder, - new Fork(0, + new Fork(nullptr, new Chain(new Hash_Filter(new CRC24), new Base64_Encoder) ) diff --git a/src/constructs/cryptobox/cryptobox.cpp b/src/constructs/cryptobox/cryptobox.cpp index bb7bf353c..aa2369c6c 100644 --- a/src/constructs/cryptobox/cryptobox.cpp +++ b/src/constructs/cryptobox/cryptobox.cpp @@ -64,7 +64,7 @@ std::string encrypt(const byte input[], size_t input_len, Pipe pipe(get_cipher("Serpent/CTR-BE", cipher_key, iv, ENCRYPTION), new Fork( - 0, + nullptr, new MAC_Filter(new HMAC(new SHA_512), mac_key, MAC_OUTPUT_LEN))); diff --git a/src/credentials/credentials_manager.cpp b/src/credentials/credentials_manager.cpp index 6013fe4ea..adb3a64fc 100644 --- a/src/credentials/credentials_manager.cpp +++ b/src/credentials/credentials_manager.cpp @@ -82,7 +82,7 @@ Private_Key* Credentials_Manager::private_key_for(const X509_Certificate&, const std::string&, const std::string&) { - return 0; + return nullptr; } std::vector<X509_Certificate> diff --git a/src/engine/asm_engine/asm_engine.cpp b/src/engine/asm_engine/asm_engine.cpp index 6d475136f..a43a3302d 100644 --- a/src/engine/asm_engine/asm_engine.cpp +++ b/src/engine/asm_engine/asm_engine.cpp @@ -40,7 +40,7 @@ Assembler_Engine::find_block_cipher(const SCAN_Name& request, #endif } - return 0; + return nullptr; } HashFunction* @@ -66,7 +66,7 @@ Assembler_Engine::find_hash(const SCAN_Name& request, #endif } - return 0; + return nullptr; } } diff --git a/src/engine/core_engine/core_modes.cpp b/src/engine/core_engine/core_modes.cpp index 8a929e880..ffd8aa04f 100644 --- a/src/engine/core_engine/core_modes.cpp +++ b/src/engine/core_engine/core_modes.cpp @@ -111,7 +111,7 @@ Keyed_Filter* get_cipher_mode(const BlockCipher* block_cipher, else return new CTS_Decryption(block_cipher->clone()); #else - return 0; + return nullptr; #endif } @@ -123,7 +123,7 @@ Keyed_Filter* get_cipher_mode(const BlockCipher* block_cipher, return new CBC_Decryption(block_cipher->clone(), get_bc_pad(padding, "PKCS7")); #else - return 0; + return nullptr; #endif } @@ -149,7 +149,7 @@ Keyed_Filter* get_cipher_mode(const BlockCipher* block_cipher, else if(algo_info.size() == 2) bits = to_u32bit(algo_info[1]); else - return 0; + return nullptr; #if defined(BOTAN_HAS_CFB) if(mode_name == "CFB") @@ -172,7 +172,7 @@ Keyed_Filter* get_cipher_mode(const BlockCipher* block_cipher, #endif } - return 0; + return nullptr; } /* @@ -195,10 +195,10 @@ Keyed_Filter* Core_Engine::get_cipher(const std::string& algo_spec, const BlockCipher* block_cipher = af.prototype_block_cipher(cipher_name); if(!block_cipher) - return 0; + return nullptr; if(algo_parts.size() >= 4) - return 0; // 4 part mode, not something we know about + return nullptr; // 4 part mode, not something we know about if(algo_parts.size() < 2) throw Lookup_Error("Cipher specification '" + algo_spec + @@ -213,7 +213,7 @@ Keyed_Filter* Core_Engine::get_cipher(const std::string& algo_spec, padding = (mode == "CBC") ? "PKCS7" : "NoPadding"; if(mode == "ECB" && padding == "CTS") - return 0; + return nullptr; else if((mode != "CBC" && mode != "ECB") && padding != "NoPadding") throw Invalid_Algorithm_Name(algo_spec); diff --git a/src/engine/core_engine/def_pk_ops.cpp b/src/engine/core_engine/def_pk_ops.cpp index db418d5bc..23ba7722c 100644 --- a/src/engine/core_engine/def_pk_ops.cpp +++ b/src/engine/core_engine/def_pk_ops.cpp @@ -58,7 +58,7 @@ Core_Engine::get_encryption_op(const Public_Key& key) const return new ElGamal_Encryption_Operation(*s); #endif - return 0; + return nullptr; } PK_Ops::Decryption* @@ -74,7 +74,7 @@ Core_Engine::get_decryption_op(const Private_Key& key) const return new ElGamal_Decryption_Operation(*s); #endif - return 0; + return nullptr; } PK_Ops::Key_Agreement* @@ -90,7 +90,7 @@ Core_Engine::get_key_agreement_op(const Private_Key& key) const return new ECDH_KA_Operation(*ecdh); #endif - return 0; + return nullptr; } PK_Ops::Signature* @@ -127,7 +127,7 @@ Core_Engine::get_signature_op(const Private_Key& key) const return new NR_Signature_Operation(*s); #endif - return 0; + return nullptr; } PK_Ops::Verification* @@ -164,7 +164,7 @@ Core_Engine::get_verify_op(const Public_Key& key) const return new NR_Verification_Operation(*s); #endif - return 0; + return nullptr; } } diff --git a/src/engine/core_engine/lookup_block.cpp b/src/engine/core_engine/lookup_block.cpp index c46d4f4cd..a02c75daa 100644 --- a/src/engine/core_engine/lookup_block.cpp +++ b/src/engine/core_engine/lookup_block.cpp @@ -277,13 +277,13 @@ BlockCipher* Core_Engine::find_block_cipher(const SCAN_Name& request, af.prototype_stream_cipher(request.arg(1)); if(!hash || !stream_cipher) - return 0; + return nullptr; return new Lion(hash->clone(), stream_cipher->clone(), block_size); } #endif - return 0; + return nullptr; } } diff --git a/src/engine/core_engine/lookup_hash.cpp b/src/engine/core_engine/lookup_hash.cpp index f94a97864..9958d18b9 100644 --- a/src/engine/core_engine/lookup_hash.cpp +++ b/src/engine/core_engine/lookup_hash.cpp @@ -218,7 +218,7 @@ HashFunction* Core_Engine::find_hash(const SCAN_Name& request, { const HashFunction* hash = af.prototype_hash_function(request.arg(i)); if(!hash) - return 0; + return nullptr; hash_prototypes.push_back(hash); } @@ -232,7 +232,7 @@ HashFunction* Core_Engine::find_hash(const SCAN_Name& request, #endif - return 0; + return nullptr; } } diff --git a/src/engine/core_engine/lookup_mac.cpp b/src/engine/core_engine/lookup_mac.cpp index 9f322b399..32275b559 100644 --- a/src/engine/core_engine/lookup_mac.cpp +++ b/src/engine/core_engine/lookup_mac.cpp @@ -64,7 +64,7 @@ Core_Engine::find_mac(const SCAN_Name& request, return new ANSI_X919_MAC(af.make_block_cipher("DES")); #endif - return 0; + return nullptr; } } diff --git a/src/engine/core_engine/lookup_pbkdf.cpp b/src/engine/core_engine/lookup_pbkdf.cpp index 9e9255f0a..2419f4373 100644 --- a/src/engine/core_engine/lookup_pbkdf.cpp +++ b/src/engine/core_engine/lookup_pbkdf.cpp @@ -46,7 +46,7 @@ PBKDF* Core_Engine::find_pbkdf(const SCAN_Name& algo_spec, return new OpenPGP_S2K(af.make_hash_function(algo_spec.arg(0))); #endif - return 0; + return nullptr; } } diff --git a/src/engine/core_engine/lookup_stream.cpp b/src/engine/core_engine/lookup_stream.cpp index 5b4859c1a..50e246756 100644 --- a/src/engine/core_engine/lookup_stream.cpp +++ b/src/engine/core_engine/lookup_stream.cpp @@ -55,7 +55,7 @@ Core_Engine::find_stream_cipher(const SCAN_Name& request, return new WiderWake_41_BE; #endif - return 0; + return nullptr; } } diff --git a/src/engine/dyn_engine/dyn_engine.cpp b/src/engine/dyn_engine/dyn_engine.cpp index 2d8dbae3b..078ec4b83 100644 --- a/src/engine/dyn_engine/dyn_engine.cpp +++ b/src/engine/dyn_engine/dyn_engine.cpp @@ -21,7 +21,7 @@ extern "C" { Dynamically_Loaded_Engine::Dynamically_Loaded_Engine( const std::string& library_path) : - engine(0) + engine(nullptr) { lib = new Dynamically_Loaded_Library(library_path); @@ -49,7 +49,7 @@ Dynamically_Loaded_Engine::Dynamically_Loaded_Engine( catch(...) { delete lib; - lib = 0; + lib = nullptr; throw; } } diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 80712a2f8..d4f6885bc 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -13,79 +13,79 @@ BlockCipher* Engine::find_block_cipher(const SCAN_Name&, Algorithm_Factory&) const { - return 0; + return nullptr; } StreamCipher* Engine::find_stream_cipher(const SCAN_Name&, Algorithm_Factory&) const { - return 0; + return nullptr; } HashFunction* Engine::find_hash(const SCAN_Name&, Algorithm_Factory&) const { - return 0; + return nullptr; } MessageAuthenticationCode* Engine::find_mac(const SCAN_Name&, Algorithm_Factory&) const { - return 0; + return nullptr; } PBKDF* Engine::find_pbkdf(const SCAN_Name&, Algorithm_Factory&) const { - return 0; + return nullptr; } Modular_Exponentiator* Engine::mod_exp(const BigInt&, Power_Mod::Usage_Hints) const { - return 0; + return nullptr; } Keyed_Filter* Engine::get_cipher(const std::string&, Cipher_Dir, Algorithm_Factory&) { - return 0; + return nullptr; } PK_Ops::Key_Agreement* Engine::get_key_agreement_op(const Private_Key&) const { - return 0; + return nullptr; } PK_Ops::Signature* Engine::get_signature_op(const Private_Key&) const { - return 0; + return nullptr; } PK_Ops::Verification* Engine::get_verify_op(const Public_Key&) const { - return 0; + return nullptr; } PK_Ops::Encryption* Engine::get_encryption_op(const Public_Key&) const { - return 0; + return nullptr; } PK_Ops::Decryption* Engine::get_decryption_op(const Private_Key&) const { - return 0; + return nullptr; } } diff --git a/src/engine/simd_engine/simd_engine.cpp b/src/engine/simd_engine/simd_engine.cpp index f9a731a82..70529f1fd 100644 --- a/src/engine/simd_engine/simd_engine.cpp +++ b/src/engine/simd_engine/simd_engine.cpp @@ -68,7 +68,7 @@ SIMD_Engine::find_block_cipher(const SCAN_Name& request, return new XTEA_SIMD; #endif - return 0; + return nullptr; } HashFunction* @@ -80,7 +80,7 @@ SIMD_Engine::find_hash(const SCAN_Name& request, return new SHA_160_SSE2; #endif - return 0; + return nullptr; } } diff --git a/src/entropy/dev_random/dev_random.cpp b/src/entropy/dev_random/dev_random.cpp index d92176ce9..3090f9510 100644 --- a/src/entropy/dev_random/dev_random.cpp +++ b/src/entropy/dev_random/dev_random.cpp @@ -45,7 +45,7 @@ size_t Device_EntropySource::Device_Reader::get(byte out[], size_t length, timeout.tv_sec = (ms_wait_time / 1000); timeout.tv_usec = (ms_wait_time % 1000) * 1000; - if(::select(fd + 1, &read_set, 0, 0, &timeout) < 0) + if(::select(fd + 1, &read_set, nullptr, nullptr, &timeout) < 0) return 0; if(!(FD_ISSET(fd, &read_set))) diff --git a/src/entropy/proc_walk/es_ftw.cpp b/src/entropy/proc_walk/es_ftw.cpp index d65aadfb1..7d72e7752 100644 --- a/src/entropy/proc_walk/es_ftw.cpp +++ b/src/entropy/proc_walk/es_ftw.cpp @@ -42,7 +42,7 @@ class Directory_Walker : public File_Descriptor_Source { public: Directory_Walker(const std::string& root) : - m_cur_dir(std::make_pair<DIR*, std::string>(0, "")) + m_cur_dir(std::make_pair<DIR*, std::string>(nullptr, "")) { if(DIR* root_dir = ::opendir(root.c_str())) m_cur_dir = std::make_pair(root_dir, root); @@ -75,9 +75,9 @@ std::pair<struct dirent*, std::string> Directory_Walker::get_next_dirent() return std::make_pair(dir, m_cur_dir.second); ::closedir(m_cur_dir.first); - m_cur_dir = std::make_pair<DIR*, std::string>(0, ""); + m_cur_dir = std::make_pair<DIR*, std::string>(nullptr, ""); - while(!m_dirlist.empty() && m_cur_dir.first == 0) + while(!m_dirlist.empty() && !m_cur_dir.first) { const std::string next_dir_name = m_dirlist[0]; m_dirlist.pop_front(); @@ -87,7 +87,7 @@ std::pair<struct dirent*, std::string> Directory_Walker::get_next_dirent() } } - return std::make_pair<struct dirent*, std::string>(0, ""); // nothing left + return std::make_pair<struct dirent*, std::string>(nullptr, ""); // nothing left } int Directory_Walker::next_fd() @@ -131,9 +131,8 @@ int Directory_Walker::next_fd() /** * FTW_EntropySource Constructor */ -FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p) +FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p), dir(nullptr) { - dir = 0; } /** @@ -142,6 +141,7 @@ FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p) FTW_EntropySource::~FTW_EntropySource() { delete dir; + dir = nullptr; } void FTW_EntropySource::poll(Entropy_Accumulator& accum) @@ -161,7 +161,7 @@ void FTW_EntropySource::poll(Entropy_Accumulator& accum) if(fd == -1) { delete dir; - dir = 0; + dir = nullptr; break; } diff --git a/src/entropy/unix_procs/es_unix.cpp b/src/entropy/unix_procs/es_unix.cpp index 9ec5f7148..f72a691d2 100644 --- a/src/entropy/unix_procs/es_unix.cpp +++ b/src/entropy/unix_procs/es_unix.cpp @@ -68,7 +68,7 @@ void Unix_EntropySource::poll(Entropy_Accumulator& accum) "/etc/passwd", ".", "..", - 0 }; + nullptr }; for(size_t i = 0; stat_targets[i]; i++) { diff --git a/src/entropy/unix_procs/unix_cmd.cpp b/src/entropy/unix_procs/unix_cmd.cpp index 930444075..823da2717 100644 --- a/src/entropy/unix_procs/unix_cmd.cpp +++ b/src/entropy/unix_procs/unix_cmd.cpp @@ -29,10 +29,10 @@ void do_exec(const std::vector<std::string>& arg_list, { const size_t args = arg_list.size() - 1; - const char* arg1 = (args >= 1) ? arg_list[1].c_str() : 0; - const char* arg2 = (args >= 2) ? arg_list[2].c_str() : 0; - const char* arg3 = (args >= 3) ? arg_list[3].c_str() : 0; - const char* arg4 = (args >= 4) ? arg_list[4].c_str() : 0; + const char* arg1 = (args >= 1) ? arg_list[1].c_str() : nullptr; + const char* arg2 = (args >= 2) ? arg_list[2].c_str() : nullptr; + const char* arg3 = (args >= 3) ? arg_list[3].c_str() : nullptr; + const char* arg4 = (args >= 4) ? arg_list[4].c_str() : nullptr; for(size_t j = 0; j != paths.size(); j++) { @@ -74,7 +74,7 @@ size_t DataSource_Command::read(byte buf[], size_t length) tv.tv_usec = MAX_BLOCK_USECS; ssize_t got = 0; - if(::select(pipe->fd + 1, &set, 0, 0, &tv) == 1) + if(::select(pipe->fd + 1, &set, nullptr, nullptr, &tv) == 1) { if(FD_ISSET(pipe->fd, &set)) got = ::read(pipe->fd, buf, length); @@ -182,7 +182,7 @@ void DataSource_Command::shutdown_pipe() { if(pipe) { - pid_t reaped = waitpid(pipe->pid, 0, WNOHANG); + pid_t reaped = waitpid(pipe->pid, nullptr, WNOHANG); if(reaped == 0) { @@ -191,21 +191,21 @@ void DataSource_Command::shutdown_pipe() struct ::timeval tv; tv.tv_sec = 0; tv.tv_usec = KILL_WAIT; - select(0, 0, 0, 0, &tv); + select(0, nullptr, nullptr, nullptr, &tv); - reaped = ::waitpid(pipe->pid, 0, WNOHANG); + reaped = ::waitpid(pipe->pid, nullptr, WNOHANG); if(reaped == 0) { ::kill(pipe->pid, SIGKILL); do - reaped = ::waitpid(pipe->pid, 0, 0); + reaped = ::waitpid(pipe->pid, nullptr, 0); while(reaped == -1); } } delete pipe; - pipe = 0; + pipe = nullptr; } } @@ -223,7 +223,7 @@ DataSource_Command::DataSource_Command(const std::string& prog_and_args, if(arg_list.size() > 5) throw Invalid_Argument("DataSource_Command: Too many args"); - pipe = 0; + pipe = nullptr; create_pipe(paths); } diff --git a/src/filters/basefilt.h b/src/filters/basefilt.h index adde3dd54..5252be973 100644 --- a/src/filters/basefilt.h +++ b/src/filters/basefilt.h @@ -39,7 +39,8 @@ class BOTAN_DLL Chain : public Fanout_Filter * Construct a chain of up to four filters. The filters are set * up in the same order as the arguments. */ - Chain(Filter* = 0, Filter* = 0, Filter* = 0, Filter* = 0); + Chain(Filter* = nullptr, Filter* = nullptr, + Filter* = nullptr, Filter* = nullptr); /** * Construct a chain from range of filters @@ -65,7 +66,7 @@ class BOTAN_DLL Fork : public Fanout_Filter /** * Construct a Fork filter with up to four forks. */ - Fork(Filter*, Filter*, Filter* = 0, Filter* = 0); + Fork(Filter*, Filter*, Filter* = nullptr, Filter* = nullptr); /** * Construct a Fork from range of filters diff --git a/src/filters/data_snk.cpp b/src/filters/data_snk.cpp index d651dcba7..2903e5e1f 100644 --- a/src/filters/data_snk.cpp +++ b/src/filters/data_snk.cpp @@ -29,7 +29,7 @@ void DataSink_Stream::write(const byte out[], size_t length) DataSink_Stream::DataSink_Stream(std::ostream& out, const std::string& name) : identifier(name), - sink_p(0), + sink_p(nullptr), sink(out) { } diff --git a/src/filters/data_src.cpp b/src/filters/data_src.cpp index 4980507ca..cc100ab13 100644 --- a/src/filters/data_src.cpp +++ b/src/filters/data_src.cpp @@ -174,7 +174,7 @@ DataSource_Stream::DataSource_Stream(const std::string& path, DataSource_Stream::DataSource_Stream(std::istream& in, const std::string& name) : identifier(name), - source_p(0), + source_p(nullptr), source(in), total_read(0) { diff --git a/src/filters/filter.cpp b/src/filters/filter.cpp index c33f25814..9432f0304 100644 --- a/src/filters/filter.cpp +++ b/src/filters/filter.cpp @@ -96,7 +96,7 @@ Filter* Filter::get_next() const { if(port_num < next.size()) return next[port_num]; - return 0; + return nullptr; } /* @@ -104,7 +104,7 @@ Filter* Filter::get_next() const */ void Filter::set_next(Filter* filters[], size_t size) { - while(size && filters && filters[size-1] == 0) + while(size && filters && filters[size-1] == nullptr) --size; next.clear(); diff --git a/src/filters/modes/eax/eax.cpp b/src/filters/modes/eax/eax.cpp index fb75d73fd..e67f03f68 100644 --- a/src/filters/modes/eax/eax.cpp +++ b/src/filters/modes/eax/eax.cpp @@ -70,7 +70,7 @@ void EAX_Base::set_key(const SymmetricKey& key) ctr->set_key(key); cmac->set_key(key); - header_mac = eax_prf(1, BLOCK_SIZE, cmac, 0, 0); + header_mac = eax_prf(1, BLOCK_SIZE, cmac, nullptr, 0); } /* diff --git a/src/filters/out_buf.cpp b/src/filters/out_buf.cpp index 7b79b4b70..b1dc8ff7f 100644 --- a/src/filters/out_buf.cpp +++ b/src/filters/out_buf.cpp @@ -69,7 +69,7 @@ void Output_Buffers::retire() if(buffers[i] && buffers[i]->size() == 0) { delete buffers[i]; - buffers[i] = 0; + buffers[i] = nullptr; } while(buffers.size() && !buffers[0]) @@ -85,7 +85,7 @@ void Output_Buffers::retire() SecureQueue* Output_Buffers::get(Pipe::message_id msg) const { if(msg < offset) - return 0; + return nullptr; BOTAN_ASSERT(msg < message_count(), "Message number out of range"); diff --git a/src/filters/pipe.cpp b/src/filters/pipe.cpp index 6664098b3..e3c2f53b6 100644 --- a/src/filters/pipe.cpp +++ b/src/filters/pipe.cpp @@ -66,7 +66,7 @@ Pipe::~Pipe() void Pipe::init() { outputs = new Output_Buffers; - pipe = 0; + pipe = nullptr; default_read = 0; inside_msg = false; } @@ -77,7 +77,7 @@ void Pipe::init() void Pipe::reset() { destruct(pipe); - pipe = 0; + pipe = nullptr; inside_msg = false; } @@ -159,7 +159,7 @@ void Pipe::start_msg() { if(inside_msg) throw Invalid_State("Pipe::start_msg: Message was already started"); - if(pipe == 0) + if(pipe == nullptr) pipe = new Null_Filter; find_endpoints(pipe); pipe->new_msg(); @@ -178,7 +178,7 @@ void Pipe::end_msg() if(dynamic_cast<Null_Filter*>(pipe)) { delete pipe; - pipe = 0; + pipe = nullptr; } inside_msg = false; @@ -210,7 +210,7 @@ void Pipe::clear_endpoints(Filter* f) for(size_t j = 0; j != f->total_ports(); ++j) { if(f->next[j] && dynamic_cast<SecureQueue*>(f->next[j])) - f->next[j] = 0; + f->next[j] = nullptr; clear_endpoints(f->next[j]); } } diff --git a/src/filters/pipe.h b/src/filters/pipe.h index e53f0d508..3236e7c36 100644 --- a/src/filters/pipe.h +++ b/src/filters/pipe.h @@ -276,7 +276,8 @@ class BOTAN_DLL Pipe : public DataSource * Construct a Pipe of up to four filters. The filters are set up * in the same order as the arguments. */ - Pipe(Filter* = 0, Filter* = 0, Filter* = 0, Filter* = 0); + Pipe(Filter* = nullptr, Filter* = nullptr, + Filter* = nullptr, Filter* = nullptr); /** * Construct a Pipe from a list of filters diff --git a/src/filters/secqueue.cpp b/src/filters/secqueue.cpp index 63d4f88d3..811a7ef57 100644 --- a/src/filters/secqueue.cpp +++ b/src/filters/secqueue.cpp @@ -17,9 +17,9 @@ class SecureQueueNode { public: SecureQueueNode() : buffer(DEFAULT_BUFFERSIZE) - { next = 0; start = end = 0; } + { next = nullptr; start = end = 0; } - ~SecureQueueNode() { next = 0; start = end = 0; } + ~SecureQueueNode() { next = nullptr; start = end = 0; } size_t write(const byte input[], size_t length) { @@ -59,7 +59,7 @@ class SecureQueueNode */ SecureQueue::SecureQueue() { - set_next(0, 0); + set_next(nullptr, 0); head = tail = new SecureQueueNode; } @@ -69,7 +69,7 @@ SecureQueue::SecureQueue() SecureQueue::SecureQueue(const SecureQueue& input) : Fanout_Filter(), DataSource() { - set_next(0, 0); + set_next(nullptr, 0); head = tail = new SecureQueueNode; SecureQueueNode* temp = input.head; @@ -92,7 +92,7 @@ void SecureQueue::destroy() delete temp; temp = holder; } - head = tail = 0; + head = tail = nullptr; } /* diff --git a/src/libstate/get_enc.cpp b/src/libstate/get_enc.cpp index b7c9a7146..00297464b 100644 --- a/src/libstate/get_enc.cpp +++ b/src/libstate/get_enc.cpp @@ -151,7 +151,7 @@ EME* get_eme(const std::string& algo_spec) Algorithm_Factory& af = global_state().algorithm_factory(); if(request.algo_name() == "Raw") - return 0; // No padding + return nullptr; // No padding #if defined(BOTAN_HAS_EME_PKCS1v15) if(request.algo_name() == "PKCS1v15" && request.arg_count() == 0) @@ -182,7 +182,7 @@ KDF* get_kdf(const std::string& algo_spec) Algorithm_Factory& af = global_state().algorithm_factory(); if(request.algo_name() == "Raw") - return 0; // No KDF + return nullptr; // No KDF #if defined(BOTAN_HAS_KDF1) if(request.algo_name() == "KDF1" && request.arg_count() == 1) diff --git a/src/libstate/global_rng.cpp b/src/libstate/global_rng.cpp index f80146596..65da38f5f 100644 --- a/src/libstate/global_rng.cpp +++ b/src/libstate/global_rng.cpp @@ -169,7 +169,7 @@ class Serialized_PRNG : public RandomNumberGenerator RandomNumberGenerator* Library_State::make_global_rng(Algorithm_Factory& af, std::mutex& mutex) { - RandomNumberGenerator* rng = 0; + RandomNumberGenerator* rng = nullptr; #if defined(BOTAN_HAS_HMAC_RNG) diff --git a/src/libstate/global_state.cpp b/src/libstate/global_state.cpp index 34bcd03fc..6a846d9b0 100644 --- a/src/libstate/global_state.cpp +++ b/src/libstate/global_state.cpp @@ -22,7 +22,7 @@ namespace Global_State_Management { */ namespace { -Library_State* global_lib_state = 0; +Library_State* global_lib_state = nullptr; } @@ -83,7 +83,7 @@ Library_State* swap_global_state(Library_State* new_state) */ bool global_state_exists() { - return (global_lib_state != 0); + return (global_lib_state != nullptr); } } diff --git a/src/libstate/init.cpp b/src/libstate/init.cpp index 6ab303909..2d724f366 100644 --- a/src/libstate/init.cpp +++ b/src/libstate/init.cpp @@ -41,7 +41,7 @@ void LibraryInitializer::initialize(const std::string&) */ void LibraryInitializer::deinitialize() { - Global_State_Management::set_global_state(0); + Global_State_Management::set_global_state(nullptr); } } diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index eafa6dbb0..7ddfddfca 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -168,9 +168,9 @@ void Library_State::initialize() */ Library_State::Library_State() { - m_algorithm_factory = 0; + m_algorithm_factory = nullptr; - global_rng_ptr = 0; + global_rng_ptr = nullptr; } /* @@ -179,10 +179,10 @@ Library_State::Library_State() Library_State::~Library_State() { delete m_algorithm_factory; - m_algorithm_factory = 0; + m_algorithm_factory = nullptr; delete global_rng_ptr; - global_rng_ptr = 0; + global_rng_ptr = nullptr; } } diff --git a/src/libstate/lookup.h b/src/libstate/lookup.h index e10c195b8..96364e1d9 100644 --- a/src/libstate/lookup.h +++ b/src/libstate/lookup.h @@ -235,7 +235,7 @@ BOTAN_DLL bool have_algorithm(const std::string& algo_spec); inline bool have_block_cipher(const std::string& algo_spec) { Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_block_cipher(algo_spec) != 0); + return (af.prototype_block_cipher(algo_spec) != nullptr); } /** @@ -248,7 +248,7 @@ inline bool have_block_cipher(const std::string& algo_spec) inline bool have_stream_cipher(const std::string& algo_spec) { Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_stream_cipher(algo_spec) != 0); + return (af.prototype_stream_cipher(algo_spec) != nullptr); } /** @@ -261,7 +261,7 @@ inline bool have_stream_cipher(const std::string& algo_spec) inline bool have_hash(const std::string& algo_spec) { Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_hash_function(algo_spec) != 0); + return (af.prototype_hash_function(algo_spec) != nullptr); } /** @@ -274,7 +274,7 @@ inline bool have_hash(const std::string& algo_spec) inline bool have_mac(const std::string& algo_spec) { Algorithm_Factory& af = global_state().algorithm_factory(); - return (af.prototype_mac(algo_spec) != 0); + return (af.prototype_mac(algo_spec) != nullptr); } /* diff --git a/src/math/numbertheory/pow_mod.cpp b/src/math/numbertheory/pow_mod.cpp index bf6b29275..c7d7fe70e 100644 --- a/src/math/numbertheory/pow_mod.cpp +++ b/src/math/numbertheory/pow_mod.cpp @@ -16,7 +16,7 @@ namespace Botan { */ Power_Mod::Power_Mod(const BigInt& n, Usage_Hints hints) { - core = 0; + core = nullptr; set_modulus(n, hints); } @@ -25,7 +25,7 @@ Power_Mod::Power_Mod(const BigInt& n, Usage_Hints hints) */ Power_Mod::Power_Mod(const Power_Mod& other) { - core = 0; + core = nullptr; if(other.core) core = other.core->copy(); } @@ -36,7 +36,7 @@ Power_Mod::Power_Mod(const Power_Mod& other) Power_Mod& Power_Mod::operator=(const Power_Mod& other) { delete core; - core = 0; + core = nullptr; if(other.core) core = other.core->copy(); return (*this); @@ -56,7 +56,7 @@ Power_Mod::~Power_Mod() void Power_Mod::set_modulus(const BigInt& n, Usage_Hints hints) const { delete core; - core = 0; + core = nullptr; if(n != 0) { diff --git a/src/passhash/passhash9/passhash9.cpp b/src/passhash/passhash9/passhash9.cpp index cbfe668f1..af7ed761b 100644 --- a/src/passhash/passhash9/passhash9.cpp +++ b/src/passhash/passhash9/passhash9.cpp @@ -40,7 +40,7 @@ MessageAuthenticationCode* get_pbkdf_prf(byte alg_id) } catch(Algorithm_Not_Found) {} - return 0; + return nullptr; } } @@ -120,7 +120,7 @@ bool check_passhash9(const std::string& pass, const std::string& hash) MessageAuthenticationCode* pbkdf_prf = get_pbkdf_prf(alg_id); - if(pbkdf_prf == 0) + if(!pbkdf_prf) return false; // unknown algorithm, reject PKCS5_PBKDF2 kdf(pbkdf_prf); // takes ownership of pointer diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp index 384fc3d90..752a4fb6d 100644 --- a/src/pbe/pbes2/pbes2.cpp +++ b/src/pbe/pbes2/pbes2.cpp @@ -228,8 +228,8 @@ PBE_PKCS5v20::PBE_PKCS5v20(BlockCipher* cipher, */ PBE_PKCS5v20::PBE_PKCS5v20(DataSource& params) : direction(DECRYPTION) { - hash_function = 0; - block_cipher = 0; + hash_function = nullptr; + block_cipher = nullptr; decode_params(params); } diff --git a/src/pk_pad/emsa3/emsa3.cpp b/src/pk_pad/emsa3/emsa3.cpp index 493140a63..0d603c508 100644 --- a/src/pk_pad/emsa3/emsa3.cpp +++ b/src/pk_pad/emsa3/emsa3.cpp @@ -129,7 +129,7 @@ secure_vector<byte> EMSA3_Raw::encoding_of(const secure_vector<byte>& msg, size_t output_bits, RandomNumberGenerator&) { - return emsa3_encoding(msg, output_bits, 0, 0); + return emsa3_encoding(msg, output_bits, nullptr, 0); } /* @@ -141,7 +141,7 @@ bool EMSA3_Raw::verify(const secure_vector<byte>& coded, { try { - return (coded == emsa3_encoding(raw, key_bits, 0, 0)); + return (coded == emsa3_encoding(raw, key_bits, nullptr, 0)); } catch(...) { diff --git a/src/pubkey/pk_algs.cpp b/src/pubkey/pk_algs.cpp index 863eb57e4..9673199e0 100644 --- a/src/pubkey/pk_algs.cpp +++ b/src/pubkey/pk_algs.cpp @@ -98,7 +98,7 @@ Public_Key* make_public_key(const AlgorithmIdentifier& alg_id, return new ECDH_PublicKey(alg_id, key_bits); #endif - return 0; + return nullptr; } Private_Key* make_private_key(const AlgorithmIdentifier& alg_id, @@ -154,7 +154,7 @@ Private_Key* make_private_key(const AlgorithmIdentifier& alg_id, return new ECDH_PrivateKey(alg_id, key_bits); #endif - return 0; + return nullptr; } } diff --git a/src/pubkey/pubkey.cpp b/src/pubkey/pubkey.cpp index 370eeddbf..c27cf4a05 100644 --- a/src/pubkey/pubkey.cpp +++ b/src/pubkey/pubkey.cpp @@ -38,7 +38,7 @@ PK_Encryptor_EME::PK_Encryptor_EME(const Public_Key& key, throw Lookup_Error("PK_Encryptor_EME: No working engine for " + key.algo_name()); - eme = (eme_name == "Raw") ? 0 : get_eme(eme_name); + eme = (eme_name == "Raw") ? nullptr : get_eme(eme_name); } /* @@ -98,7 +98,7 @@ PK_Decryptor_EME::PK_Decryptor_EME(const Private_Key& key, throw Lookup_Error("PK_Decryptor_EME: No working engine for " + key.algo_name()); - eme = (eme_name == "Raw") ? 0 : get_eme(eme_name); + eme = (eme_name == "Raw") ? nullptr : get_eme(eme_name); } /* @@ -130,8 +130,8 @@ PK_Signer::PK_Signer(const Private_Key& key, { Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); - op = 0; - verify_op = 0; + op = nullptr; + verify_op = nullptr; while(const Engine* engine = i.next()) { @@ -370,7 +370,7 @@ PK_Key_Agreement::PK_Key_Agreement(const PK_Key_Agreement_Key& key, throw Lookup_Error("PK_Key_Agreement: No working engine for " + key.algo_name()); - kdf = (kdf_name == "Raw") ? 0 : get_kdf(kdf_name); + kdf = (kdf_name == "Raw") ? nullptr : get_kdf(kdf_name); } SymmetricKey PK_Key_Agreement::derive_key(size_t key_len, const byte in[], diff --git a/src/stream/ctr/ctr.cpp b/src/stream/ctr/ctr.cpp index 8ceac858a..87ec86c65 100644 --- a/src/stream/ctr/ctr.cpp +++ b/src/stream/ctr/ctr.cpp @@ -49,7 +49,7 @@ void CTR_BE::key_schedule(const byte key[], size_t key_len) permutation->set_key(key, key_len); // Set a default all-zeros IV - set_iv(0, 0); + set_iv(nullptr, 0); } /* diff --git a/src/stream/ofb/ofb.cpp b/src/stream/ofb/ofb.cpp index 02521581b..1137a58af 100644 --- a/src/stream/ofb/ofb.cpp +++ b/src/stream/ofb/ofb.cpp @@ -46,7 +46,7 @@ void OFB::key_schedule(const byte key[], size_t key_len) permutation->set_key(key, key_len); // Set a default all-zeros IV - set_iv(0, 0); + set_iv(nullptr, 0); } /* diff --git a/src/stream/turing/turing.cpp b/src/stream/turing/turing.cpp index c455185b0..10ac18315 100644 --- a/src/stream/turing/turing.cpp +++ b/src/stream/turing/turing.cpp @@ -273,7 +273,7 @@ void Turing::key_schedule(const byte key[], size_t length) S3[i] = (W3 & 0xFFFFFF00) | C3; } - set_iv(0, 0); + set_iv(nullptr, 0); } /* diff --git a/src/tls/rec_read.cpp b/src/tls/rec_read.cpp index 4a1d6aac1..fd57496c8 100644 --- a/src/tls/rec_read.cpp +++ b/src/tls/rec_read.cpp @@ -18,7 +18,7 @@ namespace TLS { Record_Reader::Record_Reader() : m_readbuf(TLS_HEADER_SIZE + MAX_CIPHERTEXT_SIZE), - m_mac(0) + m_mac(nullptr) { reset(); set_maximum_fragment_size(0); @@ -37,7 +37,7 @@ void Record_Reader::reset() m_cipher.reset(); delete m_mac; - m_mac = 0; + m_mac = nullptr; m_block_size = 0; m_iv_size = 0; @@ -72,7 +72,7 @@ void Record_Reader::activate(Connection_Side side, { m_cipher.reset(); delete m_mac; - m_mac = 0; + m_mac = nullptr; m_seq_no = 0; if(compression_method != NO_COMPRESSION) diff --git a/src/tls/rec_wri.cpp b/src/tls/rec_wri.cpp index 63383f85e..d18ab6594 100644 --- a/src/tls/rec_wri.cpp +++ b/src/tls/rec_wri.cpp @@ -25,7 +25,7 @@ namespace TLS { Record_Writer::Record_Writer(std::function<void (const byte[], size_t)> out) : m_output_fn(out), m_writebuf(TLS_HEADER_SIZE + MAX_CIPHERTEXT_SIZE), - m_mac(0) + m_mac(nullptr) { reset(); set_maximum_fragment_size(0); @@ -48,7 +48,7 @@ void Record_Writer::reset() m_cipher.reset(); delete m_mac; - m_mac = 0; + m_mac = nullptr; m_version = Protocol_Version(); m_block_size = 0; @@ -76,7 +76,7 @@ void Record_Writer::activate(Connection_Side side, { m_cipher.reset(); delete m_mac; - m_mac = 0; + m_mac = nullptr; if(compression_method != NO_COMPRESSION) throw Internal_Error("Negotiated unknown compression algorithm"); diff --git a/src/tls/s_kex.cpp b/src/tls/s_kex.cpp index d28b44857..48901d311 100644 --- a/src/tls/s_kex.cpp +++ b/src/tls/s_kex.cpp @@ -33,7 +33,7 @@ Server_Key_Exchange::Server_Key_Exchange(Record_Writer& writer, Credentials_Manager& creds, RandomNumberGenerator& rng, const Private_Key* signing_key) : - m_kex_key(0), m_srp_params(0) + m_kex_key(nullptr), m_srp_params(nullptr) { const std::string hostname = state->client_hello->sni_hostname(); const std::string kex_algo = state->suite.kex_algo(); @@ -146,7 +146,7 @@ Server_Key_Exchange::Server_Key_Exchange(const std::vector<byte>& buf, const std::string& kex_algo, const std::string& sig_algo, Protocol_Version version) : - m_kex_key(0), m_srp_params(0) + m_kex_key(nullptr), m_srp_params(nullptr) { if(buf.size() < 6) throw Decoding_Error("Server_Key_Exchange: Packet corrupted"); diff --git a/src/tls/tls_channel.cpp b/src/tls/tls_channel.cpp index ff6722b5e..dadf26e90 100644 --- a/src/tls/tls_channel.cpp +++ b/src/tls/tls_channel.cpp @@ -22,7 +22,7 @@ Channel::Channel(std::function<void (const byte[], size_t)> socket_output_fn, proc_fn(proc_fn), handshake_fn(handshake_complete), writer(socket_output_fn), - state(0), + state(nullptr), handshake_completed(false), connection_closed(false), m_peer_supports_heartbeats(false), @@ -33,7 +33,7 @@ Channel::Channel(std::function<void (const byte[], size_t)> socket_output_fn, Channel::~Channel() { delete state; - state = 0; + state = nullptr; } size_t Channel::received_data(const byte buf[], size_t buf_size) @@ -105,7 +105,7 @@ size_t Channel::received_data(const byte buf[], size_t buf_size) alert_notify(alert_msg); - proc_fn(0, 0, alert_msg); + proc_fn(nullptr, 0, alert_msg); if(alert_msg.type() == Alert::CLOSE_NOTIFY) { @@ -120,7 +120,7 @@ size_t Channel::received_data(const byte buf[], size_t buf_size) connection_closed = true; delete state; - state = 0; + state = nullptr; writer.reset(); reader.reset(); @@ -238,7 +238,7 @@ void Channel::send_alert(const Alert& alert) connection_closed = true; delete state; - state = 0; + state = nullptr; writer.reset(); } diff --git a/src/tls/tls_channel.h b/src/tls/tls_channel.h index 46dafc416..fc0595064 100644 --- a/src/tls/tls_channel.h +++ b/src/tls/tls_channel.h @@ -69,7 +69,7 @@ class BOTAN_DLL Channel /** * Attempt to send a heartbeat message (if negotiated with counterparty) */ - void heartbeat() { heartbeat(0, 0); } + void heartbeat() { heartbeat(nullptr, 0); } /** * @return certificate chain of the peer (may be empty) diff --git a/src/tls/tls_client.cpp b/src/tls/tls_client.cpp index feb9ef85f..1ca256f3e 100644 --- a/src/tls/tls_client.cpp +++ b/src/tls/tls_client.cpp @@ -132,7 +132,7 @@ void Client::alert_notify(const Alert& alert) if(handshake_completed && state) { delete state; - state = 0; + state = nullptr; } } } @@ -143,7 +143,7 @@ void Client::alert_notify(const Alert& alert) void Client::process_handshake_msg(Handshake_Type type, const std::vector<byte>& contents) { - if(state == 0) + if(!state) throw Unexpected_Message("Unexpected handshake message from server"); if(type == HELLO_REQUEST) @@ -157,7 +157,7 @@ void Client::process_handshake_msg(Handshake_Type type, if(!secure_renegotiation.supported() && policy.require_secure_renegotiation()) { delete state; - state = 0; + state = nullptr; // RFC 5746 section 4.2 send_alert(Alert(Alert::NO_RENEGOTIATION)); @@ -474,7 +474,7 @@ void Client::process_handshake_msg(Handshake_Type type, session_manager.remove_entry(session_info.session_id()); delete state; - state = 0; + state = nullptr; handshake_completed = true; } else diff --git a/src/tls/tls_extensions.cpp b/src/tls/tls_extensions.cpp index 0f4e3176e..df25c40a5 100644 --- a/src/tls/tls_extensions.cpp +++ b/src/tls/tls_extensions.cpp @@ -49,7 +49,7 @@ Extension* make_extension(TLS_Data_Reader& reader, return new Session_Ticket(reader, size); default: - return 0; // not known + return nullptr; // not known } } diff --git a/src/tls/tls_extensions.h b/src/tls/tls_extensions.h index 885851c95..542ac0a82 100644 --- a/src/tls/tls_extensions.h +++ b/src/tls/tls_extensions.h @@ -351,7 +351,7 @@ class Extensions if(i != extensions.end()) return dynamic_cast<T*>(i->second); - return 0; + return nullptr; } void add(Extension* extn) diff --git a/src/tls/tls_handshake_state.cpp b/src/tls/tls_handshake_state.cpp index b8f3125c8..90de7c3f9 100644 --- a/src/tls/tls_handshake_state.cpp +++ b/src/tls/tls_handshake_state.cpp @@ -82,24 +82,24 @@ u32bit bitmask_for_handshake_type(Handshake_Type type) */ Handshake_State::Handshake_State(Handshake_Reader* reader) { - client_hello = 0; - server_hello = 0; - server_certs = 0; - server_kex = 0; - cert_req = 0; - server_hello_done = 0; - next_protocol = 0; - new_session_ticket = 0; - - client_certs = 0; - client_kex = 0; - client_verify = 0; - client_finished = 0; - server_finished = 0; + client_hello = nullptr; + server_hello = nullptr; + server_certs = nullptr; + server_kex = nullptr; + cert_req = nullptr; + server_hello_done = nullptr; + next_protocol = nullptr; + new_session_ticket = nullptr; + + client_certs = nullptr; + client_kex = nullptr; + client_verify = nullptr; + client_finished = nullptr; + server_finished = nullptr; m_handshake_reader = reader; - server_rsa_kex_key = 0; + server_rsa_kex_key = nullptr; m_version = Protocol_Version::SSL_V3; diff --git a/src/tls/tls_messages.h b/src/tls/tls_messages.h index e3bdaa6a0..31c35d901 100644 --- a/src/tls/tls_messages.h +++ b/src/tls/tls_messages.h @@ -414,7 +414,7 @@ class Server_Key_Exchange : public Handshake_Message const Policy& policy, Credentials_Manager& creds, RandomNumberGenerator& rng, - const Private_Key* signing_key = 0); + const Private_Key* signing_key = nullptr); Server_Key_Exchange(const std::vector<byte>& buf, const std::string& kex_alg, diff --git a/src/tls/tls_server.cpp b/src/tls/tls_server.cpp index 7c2c4d323..241215d59 100644 --- a/src/tls/tls_server.cpp +++ b/src/tls/tls_server.cpp @@ -163,7 +163,7 @@ std::map<std::string, std::vector<X509_Certificate> > get_server_certs(const std::string& hostname, Credentials_Manager& creds) { - const char* cert_types[] = { "RSA", "DSA", "ECDSA", 0 }; + const char* cert_types[] = { "RSA", "DSA", "ECDSA", nullptr }; std::map<std::string, std::vector<X509_Certificate> > cert_chains; @@ -223,7 +223,7 @@ void Server::alert_notify(const Alert& alert) if(handshake_completed && state) { delete state; - state = 0; + state = nullptr; } } } @@ -249,7 +249,7 @@ void Server::read_handshake(byte rec_type, void Server::process_handshake_msg(Handshake_Type type, const std::vector<byte>& contents) { - if(state == 0) + if(!state) throw Unexpected_Message("Unexpected handshake message from client"); state->confirm_transition_to(type); @@ -432,7 +432,7 @@ void Server::process_handshake_msg(Handshake_Type type, cert_chains[sig_algo]); } - Private_Key* private_key = 0; + Private_Key* private_key = nullptr; if(kex_algo == "RSA" || sig_algo != "") { @@ -608,7 +608,7 @@ void Server::process_handshake_msg(Handshake_Type type, state->server_finished); delete state; - state = 0; + state = nullptr; handshake_completed = true; } else diff --git a/src/utils/dyn_load/dyn_load.cpp b/src/utils/dyn_load/dyn_load.cpp index 06b8c5df3..51afb1afe 100644 --- a/src/utils/dyn_load/dyn_load.cpp +++ b/src/utils/dyn_load/dyn_load.cpp @@ -30,7 +30,7 @@ void raise_runtime_loader_exception(const std::string& lib_name, Dynamically_Loaded_Library::Dynamically_Loaded_Library( const std::string& library) : - lib_name(library), lib(0) + lib_name(library), lib(nullptr) { #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) lib = ::dlopen(lib_name.c_str(), RTLD_LAZY); @@ -60,7 +60,7 @@ Dynamically_Loaded_Library::~Dynamically_Loaded_Library() void* Dynamically_Loaded_Library::resolve_symbol(const std::string& symbol) { - void* addr = 0; + void* addr = nullptr; #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) addr = ::dlsym(lib, symbol.c_str()); |