From 807b84081f91f1f0cd5255198ce31745d410c28c Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 19 Oct 2007 18:11:06 +0000 Subject: Remove several uses of old style C casts in favor of C++98's static_cast and reinterpret_cast --- checks/dolook2.cpp | 2 +- checks/pk.cpp | 17 ++++++++++++----- checks/validate.cpp | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'checks') diff --git a/checks/dolook2.cpp b/checks/dolook2.cpp index 53e71dc26..b6c9ba339 100644 --- a/checks/dolook2.cpp +++ b/checks/dolook2.cpp @@ -19,7 +19,7 @@ class S2K_Filter : public Filter { public: void write(const byte in[], u32bit len) - { passphrase += std::string((const char*)in, len); } + { passphrase += std::string(reinterpret_cast(in), len); } void end_msg() { s2k->change_salt(salt, salt.size()); diff --git a/checks/pk.cpp b/checks/pk.cpp index bb0a27f2a..f2c2401fd 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -28,7 +28,7 @@ using namespace Botan; static BigInt to_bigint(const std::string& h) { - return BigInt::decode((const byte*)h.data(), + return BigInt::decode(reinterpret_cast(h.data()), h.length(), BigInt::Hexadecimal); } @@ -326,7 +326,9 @@ u32bit validate_rsa_enc_pkcs8(const std::string& algo, strip_newlines(pass); /* it will have a newline thanks to the messy decoding method we use */ - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast(str[0].c_str()), + str[0].length()); + Private_Key* privkey = PKCS8::load_key(keysource, pass); RSA_PrivateKey* rsapriv = dynamic_cast(privkey); @@ -441,7 +443,8 @@ u32bit validate_rsa_ver_x509(const std::string& algo, if(str.size() != 5) /* is actually 3, parse() adds extra empty ones */ throw Exception("Invalid input from pk_valid.dat"); - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast(str[0].c_str()), + str[0].length()); Public_Key* key = X509::load_key(keysource); @@ -518,7 +521,9 @@ u32bit validate_dsa_sig(const std::string& algo, strip_newlines(pass); /* it will have a newline thanks to the messy decoding method we use */ - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast(str[0].c_str()), + str[0].length()); + Private_Key* privkey = PKCS8::load_key(keysource, pass); DSA_PrivateKey* dsapriv = dynamic_cast(privkey); @@ -545,7 +550,9 @@ u32bit validate_dsa_ver(const std::string& algo, if(str.size() != 5) /* is actually 3, parse() adds extra empty ones */ throw Exception("Invalid input from pk_valid.dat"); - DataSource_Memory keysource((const byte*)str[0].c_str(), str[0].length()); + DataSource_Memory keysource(reinterpret_cast(str[0].c_str()), + str[0].length()); + Public_Key* key = X509::load_key(keysource); DSA_PublicKey* dsakey = dynamic_cast(key); diff --git a/checks/validate.cpp b/checks/validate.cpp index b10b53b98..d634d3bb3 100644 --- a/checks/validate.cpp +++ b/checks/validate.cpp @@ -263,7 +263,7 @@ bool failed_test(const std::string& algo, bool OK = true; for(u32bit j = offset; j != offset+length; j++) - if((byte)output[j] != peekbuf[j-offset]) + if(static_cast(output[j]) != peekbuf[j-offset]) OK = false; if(!OK) -- cgit v1.2.3