diff --git a/CMakeLists.txt b/CMakeLists.txt index f98e2296..23a64f9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,8 +102,6 @@ target_link_libraries(maidsafe_common ${BoostChronoLibs} ${BoostDateTimeLibs} ${BoostFilesystemLibs} - ${BoostLocaleLibs} - ${BoostRegexLibs} ${BoostSystemLibs} ${BoostThreadLibs} ${BoostProgramOptionsLibs} diff --git a/include/maidsafe/common/authentication/detail/secure_string.h b/include/maidsafe/common/authentication/detail/secure_string.h index 9e3e3857..bb7b1717 100644 --- a/include/maidsafe/common/authentication/detail/secure_string.h +++ b/include/maidsafe/common/authentication/detail/secure_string.h @@ -23,7 +23,7 @@ #include #include -#include "boost/regex.hpp" +#include // Include this first to avoid having to wrap the cryptopp includes in a pragma to disable warnings #include "maidsafe/common/crypto.h" // NOLINT @@ -111,7 +111,7 @@ class SecureInputString { bool IsInitialised() const; bool IsFinalised() const; - bool IsValid(const boost::regex& regex) const; + bool IsValid(const std::regex& regex) const; template SecureString::Hash Hash() const; @@ -125,8 +125,8 @@ class SecureInputString { SafeString Encrypt(const StringType& decrypted_chars) const; SafeString Encrypt(const char& decrypted_char) const; SafeString Decrypt(const SafeString& encrypted_char) const; - bool ValidateEncryptedChars(const boost::regex& regex) const; - bool ValidateSecureString(const boost::regex& regex) const; + bool ValidateEncryptedChars(const std::regex& regex) const; + bool ValidateSecureString(const std::regex& regex) const; std::map encrypted_chars_; SafeString phrase_; @@ -240,7 +240,7 @@ bool SecureInputString::IsFinalised() const { } template -bool SecureInputString::IsValid(const boost::regex& regex) const { +bool SecureInputString::IsValid(const std::regex& regex) const { return IsFinalised() ? ValidateSecureString(regex) : ValidateEncryptedChars(regex); } @@ -312,7 +312,7 @@ SafeString SecureInputString::Decrypt( template bool SecureInputString::ValidateEncryptedChars( - const boost::regex& regex) const { + const std::regex& regex) const { if (!Predicate()(encrypted_chars_.size(), Size)) return false; uint32_t counter(0); @@ -320,7 +320,7 @@ bool SecureInputString::ValidateEncryptedChars( if (encrypted_char.first != counter) return false; SafeString decrypted_char(Decrypt(encrypted_char.second)); - if (!boost::regex_search(decrypted_char, regex)) + if (!std::regex_search(decrypted_char, regex)) return false; ++counter; } @@ -329,13 +329,13 @@ bool SecureInputString::ValidateEncryptedChars( template bool SecureInputString::ValidateSecureString( - const boost::regex& regex) const { + const std::regex& regex) const { SafeString decrypted_string(string()); size_type decrypted_string_size(decrypted_string.size()); if (!Predicate()(decrypted_string_size, Size)) return false; for (size_type i = 0; i != decrypted_string_size; ++i) { - if (!boost::regex_search(SafeString(1, decrypted_string[i]), regex)) + if (!std::regex_search(SafeString(1, decrypted_string[i]), regex)) return false; } return true; diff --git a/src/maidsafe/common/authentication/tests/secure_string_test.cc b/src/maidsafe/common/authentication/tests/secure_string_test.cc index 3510e485..3faafbd8 100644 --- a/src/maidsafe/common/authentication/tests/secure_string_test.cc +++ b/src/maidsafe/common/authentication/tests/secure_string_test.cc @@ -18,7 +18,7 @@ #include "maidsafe/common/authentication/detail/secure_string.h" -#include "boost/regex.hpp" +#include #include "maidsafe/common/error.h" #include "maidsafe/common/log.h" @@ -296,7 +296,7 @@ TEST(SecureStringTest, BEH_CheckPasswordIsValidForAllChars) { for (size_t i(0); i != 23; ++i) EXPECT_NO_THROW(password.Insert(i, static_cast(RandomInt32()))); - ASSERT_TRUE(password.IsValid(boost::regex("."))); + ASSERT_TRUE(password.IsValid(std::regex("."))); EXPECT_NO_THROW(password.Finalise()); } @@ -338,13 +338,13 @@ TEST(SecureStringTest, BEH_InsertInvalidPinValue) { EXPECT_NO_THROW(pin.Finalise()); ASSERT_EQ(SafeString("a123"), pin.string()); - EXPECT_TRUE(pin.IsValid(boost::regex("."))); + EXPECT_TRUE(pin.IsValid(std::regex("."))); EXPECT_THROW(pin.Value(), std::exception); EXPECT_NO_THROW(pin.Remove(0, 1)); EXPECT_NO_THROW(pin.Insert(0, '0')); EXPECT_NO_THROW(pin.Finalise()); - EXPECT_TRUE(pin.IsValid(boost::regex("."))); + EXPECT_TRUE(pin.IsValid(std::regex("."))); EXPECT_NO_THROW(pin.Finalise()); ASSERT_EQ(123, pin.Value());