Remove using-declarations for std:: types

This commit is contained in:
Alex Chernyakhovsky
2023-07-30 17:46:02 -04:00
committed by Alex Chernyakhovsky
parent 8469db91db
commit 19ad493dcb
21 changed files with 173 additions and 189 deletions
+8 -8
View File
@@ -107,13 +107,13 @@ AlignedBuffer::AlignedBuffer( size_t len, const char *data )
}
}
Base64Key::Base64Key( string printable_key )
Base64Key::Base64Key( std::string printable_key )
{
if ( printable_key.length() != 22 ) {
throw CryptoException( "Key must be 22 letters long." );
}
string base64 = printable_key + "==";
std::string base64 = printable_key + "==";
size_t len = 16;
if ( !base64_decode( base64.data(), 24, key, &len ) ) {
@@ -140,7 +140,7 @@ Base64Key::Base64Key(PRNG &prng)
prng.fill( key, sizeof( key ) );
}
string Base64Key::printable_key( void ) const
std::string Base64Key::printable_key( void ) const
{
char base64[ 24 ];
@@ -148,11 +148,11 @@ string Base64Key::printable_key( void ) const
if ( (base64[ 23 ] != '=')
|| (base64[ 22 ] != '=') ) {
throw CryptoException( string( "Unexpected output from base64_encode: " ) + string( base64, 24 ) );
throw CryptoException( std::string( "Unexpected output from base64_encode: " ) + std::string( base64, 24 ) );
}
base64[ 22 ] = 0;
return string( base64 );
return std::string( base64 );
}
Session::Session( Base64Key s_key )
@@ -197,7 +197,7 @@ Nonce::Nonce( const char *s_bytes, size_t len )
memcpy( bytes + 4, s_bytes, 8 );
}
const string Session::encrypt( const Message & plaintext )
const std::string Session::encrypt( const Message & plaintext )
{
const size_t pt_len = plaintext.text.size();
const int ciphertext_len = pt_len + 16;
@@ -242,7 +242,7 @@ const string Session::encrypt( const Message & plaintext )
throw CryptoException( "Encrypted 2^47 blocks.", true );
}
string text( ciphertext_buffer.data(), ciphertext_len );
std::string text( ciphertext_buffer.data(), ciphertext_len );
return plaintext.nonce.cc_str() + text;
}
@@ -280,7 +280,7 @@ const Message Session::decrypt( const char *str, size_t len )
throw CryptoException( "Packet failed integrity check." );
}
const Message ret( nonce, string( plaintext_buffer.data(), pt_len ) );
const Message ret( nonce, std::string( plaintext_buffer.data(), pt_len ) );
return ret;
}
+9 -11
View File
@@ -46,13 +46,11 @@ long int myatoi( const char *str );
class PRNG;
namespace Crypto {
using std::string;
class CryptoException : public std::exception {
public:
string text;
std::string text;
bool fatal;
CryptoException( string s_text, bool s_fatal = false )
CryptoException( std::string s_text, bool s_fatal = false )
: text( s_text ), fatal( s_fatal ) {};
const char *what() const throw () { return text.c_str(); }
~CryptoException() throw () {}
@@ -95,8 +93,8 @@ namespace Crypto {
public:
Base64Key(); /* random key */
Base64Key(PRNG &prng);
Base64Key( string printable_key );
string printable_key( void ) const;
Base64Key( std::string printable_key );
std::string printable_key( void ) const;
unsigned char *data( void ) { return key; }
};
@@ -111,7 +109,7 @@ namespace Crypto {
Nonce( uint64_t val );
Nonce( const char *s_bytes, size_t len );
string cc_str( void ) const { return string( bytes + 4, 8 ); }
std::string cc_str( void ) const { return std::string( bytes + 4, 8 ); }
const char *data( void ) const { return bytes; }
uint64_t val( void ) const;
};
@@ -119,14 +117,14 @@ namespace Crypto {
class Message {
public:
const Nonce nonce;
const string text;
const std::string text;
Message( const char *nonce_bytes, size_t nonce_len,
const char *text_bytes, size_t text_len )
: nonce( nonce_bytes, nonce_len ),
text( text_bytes, text_len ) {}
Message( const Nonce & s_nonce, const string & s_text )
Message( const Nonce & s_nonce, const std::string & s_text )
: nonce( s_nonce ),
text( s_text ) {}
};
@@ -150,9 +148,9 @@ namespace Crypto {
Session( Base64Key s_key );
~Session();
const string encrypt( const Message & plaintext );
const std::string encrypt( const Message & plaintext );
const Message decrypt( const char *str, size_t len );
const Message decrypt( const string & ciphertext ) {
const Message decrypt( const std::string & ciphertext ) {
return decrypt( ciphertext.data(), ciphertext.size() );
}