Remove redundant stringification for decrypt().
This commit is contained in:
@@ -250,15 +250,13 @@ const string Session::encrypt( const Message & plaintext )
|
||||
return plaintext.nonce.cc_str() + text;
|
||||
}
|
||||
|
||||
const Message Session::decrypt( const string & ciphertext )
|
||||
const Message Session::decrypt( const char *str, size_t len )
|
||||
{
|
||||
if ( ciphertext.size() < 24 ) {
|
||||
if ( len < 24 ) {
|
||||
throw CryptoException( "Ciphertext must contain nonce and tag." );
|
||||
}
|
||||
|
||||
const char *str = ciphertext.data();
|
||||
|
||||
int body_len = ciphertext.size() - 8;
|
||||
int body_len = len - 8;
|
||||
int pt_len = body_len - 16;
|
||||
|
||||
if ( pt_len < 0 ) { /* super-assertion that pt_len does not equal AE_INVALID */
|
||||
|
||||
+4
-1
@@ -151,7 +151,10 @@ namespace Crypto {
|
||||
~Session();
|
||||
|
||||
const string encrypt( const Message & plaintext );
|
||||
const Message decrypt( const string & ciphertext );
|
||||
const Message decrypt( const char *str, size_t len );
|
||||
const Message decrypt( const string & ciphertext ) {
|
||||
return decrypt( ciphertext.data(), ciphertext.size() );
|
||||
}
|
||||
|
||||
Session( const Session & );
|
||||
Session & operator=( const Session & );
|
||||
|
||||
@@ -513,7 +513,7 @@ string Connection::recv_one( int sock_to_recv, bool nonblocking )
|
||||
}
|
||||
}
|
||||
|
||||
Packet p( session.decrypt( string( msg_payload, received_len ) ) );
|
||||
Packet p( session.decrypt( msg_payload, received_len ) );
|
||||
|
||||
dos_assert( p.direction == (server ? TO_SERVER : TO_CLIENT) ); /* prevent malicious playback to sender */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user