#include "components/gcm_driver/crypto/gcm_encryption_provider.h"
#include <memory>
#include "base/base64.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "base/numerics/byte_conversions.h"
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "components/gcm_driver/common/gcm_message.h"
#include "components/gcm_driver/crypto/encryption_header_parsers.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/message_payload_parser.h"
#include "components/gcm_driver/crypto/p256_key_util.h"
#include "components/gcm_driver/crypto/proto/gcm_encryption_data.pb.h"
#include "crypto/ec_private_key.h"
#include "crypto/random.h"
namespace gcm {
namespace {
const char kEncryptionProperty[] = …;
const char kCryptoKeyProperty[] = …;
const char kInternalRawData[] = …;
const base::FilePath::CharType kEncryptionDirectoryName[] = …);
IncomingMessage CreateMessageWithId(const std::string& message_id) { … }
}
GCMEncryptionProvider::GCMEncryptionProvider() { … }
GCMEncryptionProvider::~GCMEncryptionProvider() = default;
const char GCMEncryptionProvider::kContentEncodingProperty[] = …;
const char GCMEncryptionProvider::kContentCodingAes128Gcm[] = …;
void GCMEncryptionProvider::Init(
const base::FilePath& store_path,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) { … }
void GCMEncryptionProvider::GetEncryptionInfo(
const std::string& app_id,
const std::string& authorized_entity,
EncryptionInfoCallback callback) { … }
void GCMEncryptionProvider::DidGetEncryptionInfo(
const std::string& app_id,
const std::string& authorized_entity,
EncryptionInfoCallback callback,
std::unique_ptr<crypto::ECPrivateKey> key,
const std::string& auth_secret) { … }
void GCMEncryptionProvider::RemoveEncryptionInfo(
const std::string& app_id,
const std::string& authorized_entity,
base::OnceClosure callback) { … }
bool GCMEncryptionProvider::IsEncryptedMessage(
const IncomingMessage& message) const { … }
void GCMEncryptionProvider::DecryptMessage(const std::string& app_id,
const IncomingMessage& message,
DecryptMessageCallback callback) { … }
void GCMEncryptionProvider::EncryptMessage(const std::string& app_id,
const std::string& authorized_entity,
const std::string& p256dh,
const std::string& auth_secret,
const std::string& message,
EncryptMessageCallback callback) { … }
void GCMEncryptionProvider::DidCreateEncryptionInfo(
EncryptionInfoCallback callback,
std::unique_ptr<crypto::ECPrivateKey> key,
const std::string& auth_secret) { … }
void GCMEncryptionProvider::DecryptMessageWithKey(
const std::string& message_id,
const std::string& collapse_key,
const std::string& sender_id,
const std::string& salt,
const std::string& public_key,
uint32_t record_size,
const std::string& ciphertext,
GCMMessageCryptographer::Version version,
DecryptMessageCallback callback,
std::unique_ptr<crypto::ECPrivateKey> key,
const std::string& auth_secret) { … }
void GCMEncryptionProvider::EncryptMessageWithKey(
const std::string& app_id,
const std::string& authorized_entity,
const std::string& p256dh,
const std::string& auth_secret,
const std::string& message,
EncryptMessageCallback callback,
std::unique_ptr<crypto::ECPrivateKey> key,
const std::string& sender_auth_secret) { … }
}