From b3db0e6ee14315d20ca91eff91e348e18dd119e6 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 13 May 2016 11:53:33 +0100 Subject: translate logging.cpp to C --- src/ratchet.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ratchet.cpp') diff --git a/src/ratchet.cpp b/src/ratchet.cpp index 03a0478..06912af 100644 --- a/src/ratchet.cpp +++ b/src/ratchet.cpp @@ -17,7 +17,7 @@ #include "olm/memory.hh" #include "olm/cipher.hh" #include "olm/pickle.hh" -#include "olm/logging.hh" +#include "olm/logging.h" #include @@ -79,7 +79,7 @@ static void advance_chain_key( new_chain_key.key ); new_chain_key.index = chain_key.index + 1; - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Derived chain key C(%i,%i)", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Derived chain key C(%i,%i)", chain_index, new_chain_key.index); } @@ -95,7 +95,7 @@ static void create_message_keys( message_key.key ); message_key.index = chain_key.index; - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Created message key with chain key C(%i,%i)", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Created message key with chain key C(%i,%i)", chain_index, message_key.index); } @@ -176,7 +176,7 @@ static std::size_t verify_mac_and_decrypt_for_new_chain( new_chain.ratchet_key, session.kdf_info, new_root_key, new_chain.chain_key ); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Calculated new receiver chain R(%i)", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Calculated new receiver chain R(%i)", chain_index); std::size_t result = verify_mac_and_decrypt_for_existing_chain( @@ -219,7 +219,7 @@ void olm::Ratchet::initialise_as_bob( receiver_chains[0].ratchet_key = their_ratchet_key; chain_index = 0; olm::unset(derived_secrets); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Initialised receiver chain R(0)"); + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised receiver chain R(0)"); } @@ -242,7 +242,7 @@ void olm::Ratchet::initialise_as_alice( sender_chain[0].ratchet_key = our_ratchet_key; chain_index = 0; olm::unset(derived_secrets); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Initialised sender chain R(0)"); + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised sender chain R(0)"); } namespace olm { @@ -450,7 +450,7 @@ std::size_t olm::Ratchet::encrypt( if (sender_chain.empty()) { sender_chain.insert(); olm::curve25519_generate_key(random, sender_chain[0].ratchet_key); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Created new ratchet key T(%i) %s", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Created new ratchet key T(%i) %s", chain_index + 1, sender_chain[0].ratchet_key.to_string().c_str()); create_chain_key( @@ -460,7 +460,7 @@ std::size_t olm::Ratchet::encrypt( kdf_info, root_key, sender_chain[0].chain_key ); - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Initialised new sender chain R(%i)", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised new sender chain R(%i)", chain_index + 1); chain_index++; } @@ -491,7 +491,7 @@ std::size_t olm::Ratchet::encrypt( output, output_length ); - olm::logf(olm::LOG_TRACE, LOG_CATEGORY, + olm_logf(OLM_LOG_TRACE, LOG_CATEGORY, "Encoded message ver=%i ratchet_key=%s chain_idx=%i ciphertext=%s", PROTOCOL_VERSION, olm::bytes_to_string(writer.ratchet_key, olm::KEY_LENGTH).c_str(), @@ -525,7 +525,7 @@ std::size_t olm::Ratchet::decrypt( std::uint8_t const * input, std::size_t input_length, std::uint8_t * plaintext, std::size_t max_plaintext_length ) { - olm::logf(olm::LOG_TRACE, LOG_CATEGORY, + olm_logf(OLM_LOG_TRACE, LOG_CATEGORY, "Decrypting message %s", olm::bytes_to_string(input, input_length).c_str()); @@ -580,7 +580,7 @@ std::size_t olm::Ratchet::decrypt( std::size_t result = std::size_t(-1); if (!chain) { - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Sender ratchet key does not match known chain; starting new one"); result = verify_mac_and_decrypt_for_new_chain( *this, reader, plaintext, max_plaintext_length @@ -642,7 +642,7 @@ std::size_t olm::Ratchet::decrypt( olm::unset(sender_chain[0]); sender_chain.erase(sender_chain.begin()); receiver_chain_index = ++chain_index; - olm::logf(olm::LOG_DEBUG, LOG_CATEGORY, "Initialised new receiver chain R(%i)", + olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised new receiver chain R(%i)", chain_index); } -- cgit v1.2.3 From 3965320a9ce2a41a96b962e8f5bf396f328d1aad Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 16 May 2016 11:13:54 +0100 Subject: Remove logging functionality Concerns have been raised that including logging functionality makes it harder to audit the implementation to ensure that no secret information is leaked. We are therefore removing it from the master branch. --- src/ratchet.cpp | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'src/ratchet.cpp') diff --git a/src/ratchet.cpp b/src/ratchet.cpp index 06912af..b04099f 100644 --- a/src/ratchet.cpp +++ b/src/ratchet.cpp @@ -17,14 +17,11 @@ #include "olm/memory.hh" #include "olm/cipher.hh" #include "olm/pickle.hh" -#include "olm/logging.h" #include namespace { -static const char *LOG_CATEGORY = "olm::Ratchet"; - static const std::uint8_t PROTOCOL_VERSION = 3; static const std::uint8_t MESSAGE_KEY_SEED[1] = {0x01}; static const std::uint8_t CHAIN_KEY_SEED[1] = {0x02}; @@ -79,8 +76,6 @@ static void advance_chain_key( new_chain_key.key ); new_chain_key.index = chain_key.index + 1; - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Derived chain key C(%i,%i)", - chain_index, new_chain_key.index); } @@ -95,8 +90,6 @@ static void create_message_keys( message_key.key ); message_key.index = chain_key.index; - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Created message key with chain key C(%i,%i)", - chain_index, message_key.index); } @@ -176,9 +169,6 @@ static std::size_t verify_mac_and_decrypt_for_new_chain( new_chain.ratchet_key, session.kdf_info, new_root_key, new_chain.chain_key ); - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Calculated new receiver chain R(%i)", - chain_index); - std::size_t result = verify_mac_and_decrypt_for_existing_chain( session, chain_index, new_chain.chain_key, reader, plaintext, max_plaintext_length @@ -219,7 +209,6 @@ void olm::Ratchet::initialise_as_bob( receiver_chains[0].ratchet_key = their_ratchet_key; chain_index = 0; olm::unset(derived_secrets); - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised receiver chain R(0)"); } @@ -242,7 +231,6 @@ void olm::Ratchet::initialise_as_alice( sender_chain[0].ratchet_key = our_ratchet_key; chain_index = 0; olm::unset(derived_secrets); - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised sender chain R(0)"); } namespace olm { @@ -450,9 +438,6 @@ std::size_t olm::Ratchet::encrypt( if (sender_chain.empty()) { sender_chain.insert(); olm::curve25519_generate_key(random, sender_chain[0].ratchet_key); - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Created new ratchet key T(%i) %s", - chain_index + 1, - sender_chain[0].ratchet_key.to_string().c_str()); create_chain_key( root_key, sender_chain[0].ratchet_key, @@ -460,8 +445,6 @@ std::size_t olm::Ratchet::encrypt( kdf_info, root_key, sender_chain[0].chain_key ); - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised new sender chain R(%i)", - chain_index + 1); chain_index++; } @@ -491,14 +474,6 @@ std::size_t olm::Ratchet::encrypt( output, output_length ); - olm_logf(OLM_LOG_TRACE, LOG_CATEGORY, - "Encoded message ver=%i ratchet_key=%s chain_idx=%i ciphertext=%s", - PROTOCOL_VERSION, - olm::bytes_to_string(writer.ratchet_key, olm::KEY_LENGTH).c_str(), - counter, - olm::bytes_to_string(writer.ciphertext, ciphertext_length).c_str() - ); - olm::unset(keys); return output_length; } @@ -525,10 +500,6 @@ std::size_t olm::Ratchet::decrypt( std::uint8_t const * input, std::size_t input_length, std::uint8_t * plaintext, std::size_t max_plaintext_length ) { - olm_logf(OLM_LOG_TRACE, LOG_CATEGORY, - "Decrypting message %s", - olm::bytes_to_string(input, input_length).c_str()); - olm::MessageReader reader; olm::decode_message( reader, input, input_length, ratchet_cipher.mac_length() @@ -580,8 +551,6 @@ std::size_t olm::Ratchet::decrypt( std::size_t result = std::size_t(-1); if (!chain) { - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, - "Sender ratchet key does not match known chain; starting new one"); result = verify_mac_and_decrypt_for_new_chain( *this, reader, plaintext, max_plaintext_length ); @@ -642,8 +611,6 @@ std::size_t olm::Ratchet::decrypt( olm::unset(sender_chain[0]); sender_chain.erase(sender_chain.begin()); receiver_chain_index = ++chain_index; - olm_logf(OLM_LOG_DEBUG, LOG_CATEGORY, "Initialised new receiver chain R(%i)", - chain_index); } while (chain->chain_key.index < reader.counter) { -- cgit v1.2.3