Merge branch 'develop' into feature/library_intermediate2

This commit is contained in:
Sebastian Messmer 2019-01-24 13:15:57 -08:00
commit 48dea1b13b
23 changed files with 65 additions and 60 deletions

View File

@ -1,13 +1,11 @@
image:
#- Visual Studio 2013
#- Visual Studio 2015
- Visual Studio 2017
#- Visual Studio 2017 Preview
platform:
- x64
- x86
- Any CPU
#- Any CPU
configuration:
- Debug
@ -33,7 +31,8 @@ install:
build_script:
- cmd: mkdir build
- cmd: cd build
- cmd: cmake .. -G "Ninja" -DBUILD_TESTING=on -DBOOST_ROOT="C:/Libraries/boost_1_65_1" -DDOKAN_PATH="C:/Program Files/Dokan/DokanLibrary-1.1.0"
# note: The cmake+ninja workflow requires us to set build type in both cmake commands ('cmake' and 'cmake --build'), otherwise the cryfs.exe will depend on debug versions of the visual studio c++ runtime (i.e. msvcp140d.dll)
- cmd: cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DBUILD_TESTING=on -DBOOST_ROOT="C:/Libraries/boost_1_65_1" -DDOKAN_PATH="C:/Program Files/Dokan/DokanLibrary-1.1.0"
- cmd: cmake --build . --config %CONFIGURATION%
- cmd: .\test\gitversion\gitversion-test.exe
# cpp-utils-test disables ThreadDebuggingTest_ThreadName.*_thenIsCorrect because the appveyor image is too old to support the API needed for that

View File

@ -2,8 +2,6 @@
#ifndef MESSMER_BLOCKSTORE_IMPLEMENTATIONS_COMPRESSING_COMPRESSEDBLOCK_H_
#define MESSMER_BLOCKSTORE_IMPLEMENTATIONS_COMPRESSING_COMPRESSEDBLOCK_H_
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "../../interface/Block.h"
#include "../../interface/BlockStore.h"
#include <cpp-utils/data/DataUtils.h>

View File

@ -1,4 +1,3 @@
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "Gzip.h"
#include <vendor_cryptopp/gzip.h>

View File

@ -3,7 +3,6 @@
#define MESSMER_BLOCKSTORE_IMPLEMENTATIONS_ENCRYPTED_ENCRYPTEDBLOCKSTORE2_H_
#include "../../interface/BlockStore2.h"
#include "cpp-utils/crypto/cryptopp_byte.h"
#include <cpp-utils/macros.h>
#include <cpp-utils/crypto/symmetric/Cipher.h>
#include <cpp-utils/data/SerializationHelper.h>

View File

@ -1,18 +0,0 @@
#pragma once
#ifndef _CPPUTILS_CRYPTO_CRYPTOPP_BYTE_H
#define _CPPUTILS_CRYPTO_CRYPTOPP_BYTE_H
#include <vendor_cryptopp/cryptlib.h>
// If we're running an older CryptoPP version, CryptoPP::byte isn't defined yet.
// Define it. Refer to "byte" type in the global namespace (placed by CryptoPP).
// Could also use CRYPTOPP_NO_GLOBAL_BYTE - but don't want to track when it was
// introduced. This way seems more reliable, as it is compatible with more of
// the Crypto++ versions.
#if CRYPTOPP_VERSION < 600
namespace CryptoPP {
using byte = ::byte;
}
#endif /* CRYPTOPP_VERSION < 600 */
#endif /* _CPPUTILS_CRYPTO_CRYPTOPP_BYTE_H */

View File

@ -2,7 +2,6 @@
#ifndef MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_CFBCIPHER_H_
#define MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_CFBCIPHER_H_
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "../../data/FixedSizeData.h"
#include "../../data/Data.h"
#include "../../random/Random.h"

View File

@ -5,7 +5,6 @@
#include <cpp-utils/data/FixedSizeData.h>
#include <memory>
#include <cpp-utils/system/memory.h>
#include "../cryptopp_byte.h"
#include <cpp-utils/random/RandomGenerator.h>
namespace cpputils {

View File

@ -2,7 +2,6 @@
#ifndef MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_GCMCIPHER_H_
#define MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_GCMCIPHER_H_
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "../../data/FixedSizeData.h"
#include "../../data/Data.h"
#include "../../random/Random.h"

View File

@ -23,12 +23,8 @@ namespace cpputils {
DEFINE_CIPHER(Cast256_GCM);
DEFINE_CIPHER(Cast256_CFB);
#if CRYPTOPP_VERSION != 564
DEFINE_CIPHER(Mars448_GCM);
DEFINE_CIPHER(Mars448_CFB);
#else
# warning "You're using Crypto++ 5.6.4. In this version, the MARS-448 cipher is not available. Your CryFS executable will not be able to load file systems using this cipher. Please use Crypto++ 5.6.3 or 5.6.5+ instead."
#endif
DEFINE_CIPHER(Mars256_GCM);
DEFINE_CIPHER(Mars256_CFB);
DEFINE_CIPHER(Mars128_GCM);

View File

@ -41,11 +41,9 @@ static_assert(32 == CryptoPP::CAST256::MAX_KEYLENGTH, "If Cast offered larger ke
DECLARE_CIPHER(Cast256_GCM, "cast-256-gcm", GCM_Cipher, CryptoPP::CAST256, 32);
DECLARE_CIPHER(Cast256_CFB, "cast-256-cfb", CFB_Cipher, CryptoPP::CAST256, 32);
#if CRYPTOPP_VERSION != 564
static_assert(56 == CryptoPP::MARS::MAX_KEYLENGTH, "If Mars offered larger keys, we should offer a variant with it");
DECLARE_CIPHER(Mars448_GCM, "mars-448-gcm", GCM_Cipher, CryptoPP::MARS, 56);
DECLARE_CIPHER(Mars448_CFB, "mars-448-cfb", CFB_Cipher, CryptoPP::MARS, 56);
#endif
DECLARE_CIPHER(Mars256_GCM, "mars-256-gcm", GCM_Cipher, CryptoPP::MARS, 32);
DECLARE_CIPHER(Mars256_CFB, "mars-256-cfb", CFB_Cipher, CryptoPP::MARS, 32);
DECLARE_CIPHER(Mars128_GCM, "mars-128-gcm", GCM_Cipher, CryptoPP::MARS, 16);

View File

@ -2,7 +2,6 @@
#ifndef MESSMER_CPPUTILS_TEST_CRYPTO_SYMMETRIC_TESTUTILS_FAKEAUTHENTICATEDCIPHER_H_
#define MESSMER_CPPUTILS_TEST_CRYPTO_SYMMETRIC_TESTUTILS_FAKEAUTHENTICATEDCIPHER_H_
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "cpp-utils/crypto/symmetric/Cipher.h"
#include "cpp-utils/data/FixedSizeData.h"
#include "cpp-utils/data/Data.h"

View File

@ -1,7 +1,6 @@
#include "Data.h"
#include <stdexcept>
#include <vendor_cryptopp/hex.h>
#include <cpp-utils/crypto/cryptopp_byte.h>
using std::istream;
using std::ofstream;

View File

@ -2,7 +2,6 @@
#ifndef MESSMER_CPPUTILS_RANDOM_OSRANDOMGENERATOR_H
#define MESSMER_CPPUTILS_RANDOM_OSRANDOMGENERATOR_H
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "RandomGenerator.h"
#include <vendor_cryptopp/osrng.h>

View File

@ -1,4 +1,3 @@
#include "cpp-utils/crypto/cryptopp_byte.h"
#include "RandomGeneratorThread.h"
namespace cpputils {

View File

@ -73,10 +73,8 @@ const vector<shared_ptr<CryCipher>> CryCiphers::SUPPORTED_CIPHERS = {
make_shared<CryCipherInstance<Serpent128_CFB>>(INTEGRITY_WARNING),
make_shared<CryCipherInstance<Cast256_GCM>>(),
make_shared<CryCipherInstance<Cast256_CFB>>(INTEGRITY_WARNING),
#if CRYPTOPP_VERSION != 564
make_shared<CryCipherInstance<Mars448_GCM>>(),
make_shared<CryCipherInstance<Mars448_CFB>>(INTEGRITY_WARNING),
#endif
make_shared<CryCipherInstance<Mars256_GCM>>(),
make_shared<CryCipherInstance<Mars256_CFB>>(INTEGRITY_WARNING),
make_shared<CryCipherInstance<Mars128_GCM>>(),

View File

@ -1,4 +1,3 @@
#include "cpp-utils/crypto/cryptopp_byte.h"
#include <gtest/gtest.h>
#include "cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h"
#include "blockstore/implementations/encrypted/EncryptedBlockStore2.h"

View File

@ -1,6 +1,10 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#ifdef NDEBUG
#define _REAL_NDEBUG
#endif
//Include the ASSERT macro for a debug build
#undef NDEBUG
#include "cpp-utils/assert/assert.h"
@ -29,9 +33,18 @@ constexpr const char* EXPECTED = R"(Assertion \[2==5\] failed in .*assert_debug_
);
}
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH(
ASSERT(2==5, "my message"),
"cpputils::"
);
}
#else
TEST(AssertTest_DebugBuild, AssertMessageContainsBacktrace) {
EXPECT_DEATH(
ASSERT(2==5, "my message"),
"#1"
);
}
#endif

View File

@ -2,6 +2,10 @@
#include <gmock/gmock.h>
#include <regex>
#ifdef NDEBUG
#define _REAL_NDEBUG
#endif
//Include the ASSERT macro for a release build
#ifndef NDEBUG
#define NDEBUG
@ -31,10 +35,11 @@ TEST(AssertTest_ReleaseBuild, AssertMessage) {
/*EXPECT_THAT(e.what(), MatchesRegex(
R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:27: my message)"
));*/
EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:26: my message)")));
EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:30: my message)")));
}
}
#if !(defined(_MSC_VER) && defined(_REAL_NDEBUG))
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try {
ASSERT(2==5, "my message");
@ -45,3 +50,15 @@ TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
));
}
}
#else
TEST(AssertTest_ReleaseBuild, AssertMessageContainsBacktrace) {
try {
ASSERT(2==5, "my message");
FAIL();
} catch (const cpputils::AssertFailed &e) {
EXPECT_THAT(e.what(), HasSubstr(
"#1"
));
}
}
#endif

View File

@ -19,6 +19,12 @@ namespace {
}
}
TEST(BacktraceTest, ContainsBacktrace) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("#1"));
}
#if !(defined(_MSC_VER) && defined(NDEBUG))
TEST(BacktraceTest, ContainsExecutableName) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("cpp-utils-test"));
@ -29,7 +35,7 @@ TEST(BacktraceTest, ContainsTopLevelLine) {
EXPECT_THAT(backtrace, HasSubstr("BacktraceTest"));
EXPECT_THAT(backtrace, HasSubstr("ContainsTopLevelLine"));
}
#endif
namespace {
std::string call_process_exiting_with_nullptr_violation() {
@ -77,6 +83,7 @@ TEST(BacktraceTest, DoesntCrashOnCaughtException) {
}
}
#if !(defined(_MSC_VER) && defined(NDEBUG))
TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) {
auto output = call_process_exiting_with_nullptr_violation();
EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal"));
@ -96,6 +103,27 @@ TEST(BacktraceTest, ShowBacktraceOnSigIll) {
auto output = call_process_exiting_with_sigill();
EXPECT_THAT(output, HasSubstr("cpp-utils-test_exit_signal"));
}
#else
TEST(BacktraceTest, ShowBacktraceOnNullptrAccess) {
auto output = call_process_exiting_with_nullptr_violation();
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnSigSegv) {
auto output = call_process_exiting_with_sigsegv();
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnUnhandledException) {
auto output = call_process_exiting_with_exception("my_exception_message");
EXPECT_THAT(output, HasSubstr("#1"));
}
TEST(BacktraceTest, ShowBacktraceOnSigIll) {
auto output = call_process_exiting_with_sigill();
EXPECT_THAT(output, HasSubstr("#1"));
}
#endif
#if !defined(_MSC_VER)
TEST(BacktraceTest, ShowBacktraceOnSigAbrt) {

View File

@ -1,4 +1,3 @@
#include "cpp-utils/crypto/cryptopp_byte.h"
#include <gtest/gtest.h>
#include "cpp-utils/crypto/symmetric/Cipher.h"
#include "cpp-utils/crypto/symmetric/ciphers.h"
@ -253,11 +252,9 @@ INSTANTIATE_TYPED_TEST_CASE_P(Cast256_CFB, CipherTest, Cast256_CFB); //CFB mode
INSTANTIATE_TYPED_TEST_CASE_P(Cast256_GCM, CipherTest, Cast256_GCM);
INSTANTIATE_TYPED_TEST_CASE_P(Cast256_GCM, AuthenticatedCipherTest, Cast256_GCM);
#if CRYPTOPP_VERSION != 564
INSTANTIATE_TYPED_TEST_CASE_P(Mars448_CFB, CipherTest, Mars448_CFB); //CFB mode is not authenticated
INSTANTIATE_TYPED_TEST_CASE_P(Mars448_GCM, CipherTest, Mars448_GCM);
INSTANTIATE_TYPED_TEST_CASE_P(Mars448_GCM, AuthenticatedCipherTest, Mars448_GCM);
#endif
INSTANTIATE_TYPED_TEST_CASE_P(Mars256_CFB, CipherTest, Mars256_CFB); //CFB mode is not authenticated
INSTANTIATE_TYPED_TEST_CASE_P(Mars256_GCM, CipherTest, Mars256_GCM);
INSTANTIATE_TYPED_TEST_CASE_P(Mars256_GCM, AuthenticatedCipherTest, Mars256_GCM);
@ -286,10 +283,9 @@ TEST(CipherNameTest, TestCipherNames) {
EXPECT_EQ("cast-256-gcm", string(Cast256_GCM::NAME));
EXPECT_EQ("cast-256-cfb", string(Cast256_CFB::NAME));
#if CRYPTOPP_VERSION != 564
EXPECT_EQ("mars-448-gcm", string(Mars448_GCM::NAME));
EXPECT_EQ("mars-448-cfb", string(Mars448_CFB::NAME));
#endif
EXPECT_EQ("mars-256-gcm", string(Mars256_GCM::NAME));
EXPECT_EQ("mars-256-cfb", string(Mars256_CFB::NAME));
EXPECT_EQ("mars-128-gcm", string(Mars128_GCM::NAME));

View File

@ -1,4 +1,3 @@
#include "cpp-utils/crypto/cryptopp_byte.h"
#include <gtest/gtest.h>
#include <vector>
#include <boost/filesystem.hpp>

View File

@ -77,10 +77,7 @@ TEST_F(CryCipherTest, FindsCorrectCipher) {
"aes-256-gcm", "aes-256-cfb", "aes-256-gcm", "aes-256-cfb",
"twofish-256-gcm", "twofish-256-cfb", "twofish-256-gcm", "twofish-256-cfb",
"serpent-256-gcm", "serpent-256-cfb", "serpent-256-gcm", "serpent-256-cfb",
"cast-256-gcm", "cast-256-cfb",
#if CRYPTOPP_VERSION != 564
"mars-448-gcm", "mars-448-cfb",
#endif
"cast-256-gcm", "cast-256-cfb", "mars-448-gcm", "mars-448-cfb",
"mars-256-gcm", "mars-256-cfb", "mars-256-gcm", "mars-256-cfb"
});
}
@ -100,10 +97,8 @@ TEST_F(CryCipherTest, CreatesCorrectEncryptedBlockStore) {
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Serpent128_CFB>("serpent-128-cfb");
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Cast256_GCM>("cast-256-gcm");
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Cast256_CFB>("cast-256-cfb");
#if CRYPTOPP_VERSION != 564
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Mars448_GCM>("mars-448-gcm");
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Mars448_CFB>("mars-448-cfb");
#endif
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Mars256_GCM>("mars-256-gcm");
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Mars256_CFB>("mars-256-cfb");
EXPECT_CREATES_CORRECT_ENCRYPTED_BLOCKSTORE<Mars128_GCM>("mars-128-gcm");
@ -123,11 +118,9 @@ TEST_F(CryCipherTest, ThereIsACipherWithIntegrityWarning) {
EXPECT_THAT(CryCiphers::find("aes-256-cfb").warning().value(), MatchesRegex(".*integrity.*"));
}
#if CRYPTOPP_VERSION != 564
TEST_F(CryCipherTest, EncryptionKeyHasCorrectSize_448) {
EXPECT_EQ(Mars448_GCM::STRING_KEYSIZE, CryCiphers::find("mars-448-gcm").createKey(Random::PseudoRandom()).size());
}
#endif
TEST_F(CryCipherTest, EncryptionKeyHasCorrectSize_256) {
EXPECT_EQ(AES256_GCM::STRING_KEYSIZE, CryCiphers::find("aes-256-gcm").createKey(Random::PseudoRandom()).size());

View File

@ -155,7 +155,6 @@ TEST_F(CryConfigCreatorTest, ChoosesEmptyRootBlobId) {
EXPECT_EQ("", config.RootBlob()); // This tells CryFS to create a new root blob
}
#if CRYPTOPP_VERSION != 564
TEST_F(CryConfigCreatorTest, ChoosesValidEncryptionKey_448) {
AnswerNoToDefaultSettings();
IGNORE_ASK_FOR_MISSINGBLOCKISINTEGRITYVIOLATION();
@ -163,7 +162,6 @@ TEST_F(CryConfigCreatorTest, ChoosesValidEncryptionKey_448) {
CryConfig config = creator.create(none, none, none, false).config;
cpputils::Mars448_GCM::EncryptionKey::FromString(config.EncryptionKey()); // This crashes if invalid
}
#endif
TEST_F(CryConfigCreatorTest, ChoosesValidEncryptionKey_256) {
AnswerNoToDefaultSettings();