#include "components/gcm_driver/crypto/gcm_encryption_provider.h"
#include <stddef.h>
#include <memory>
#include <sstream>
#include <string>
#include "base/base64.h"
#include "base/base64url.h"
#include "base/big_endian.h"
#include "base/containers/span.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "components/gcm_driver/common/gcm_message.h"
#include "components/gcm_driver/crypto/gcm_decryption_result.h"
#include "components/gcm_driver/crypto/gcm_encryption_result.h"
#include "components/gcm_driver/crypto/gcm_key_store.h"
#include "components/gcm_driver/crypto/gcm_message_cryptographer.h"
#include "components/gcm_driver/crypto/p256_key_util.h"
#include "crypto/random.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gcm {
namespace {
const char kExampleAppId[] = …;
const char kExampleAuthorizedEntity[] = …;
const char kExampleMessage[] = …;
const char kValidEncryptionHeader[] = …;
const char kInvalidEncryptionHeader[] = …;
const char kValidCryptoKeyHeader[] = …;
const char kValidThreeValueCryptoKeyHeader[] = …;
const char kInvalidCryptoKeyHeader[] = …;
const char kInvalidThreeValueCryptoKeyHeader[] = …;
}
ECPrivateKeyUniquePtr;
class GCMEncryptionProviderTest : public ::testing::Test { … };
TEST_F(GCMEncryptionProviderTest, IsEncryptedMessage) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesEncryptionHeaderParsing) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesCryptoKeyHeaderParsing) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesCryptoKeyHeaderParsingThirdValue) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesCryptoKeyHeaderSingleDhEntry) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesExistingKeys) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesKeyRemovalGCMRegistration) { … }
TEST_F(GCMEncryptionProviderTest, VerifiesKeyRemovalInstanceIDToken) { … }
void GCMEncryptionProviderTest::TestEncryptionRoundTrip(
const std::string& app_id,
const std::string& authorized_entity,
GCMMessageCryptographer::Version version,
bool use_internal_raw_data_for_draft08) { … }
void GCMEncryptionProviderTest::TestEncryptionNoKeys(
const std::string& app_id,
const std::string& authorized_entity) { … }
TEST_F(GCMEncryptionProviderTest, EncryptionRoundTripGCMRegistration) { … }
TEST_F(GCMEncryptionProviderTest, EncryptionRoundTripInstanceIDToken) { … }
TEST_F(GCMEncryptionProviderTest, EncryptionRoundTripDraft08) { … }
TEST_F(GCMEncryptionProviderTest, EncryptionRoundTripDraft08InternalRawData) { … }
TEST_F(GCMEncryptionProviderTest, EncryptionNoKeys) { … }
}