#include "components/gcm_driver/crypto/gcm_key_store.h"
#include <stddef.h>
#include <utility>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/sequenced_task_runner.h"
#include "components/gcm_driver/crypto/p256_key_util.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/leveldb_proto/public/shared_proto_database_client_list.h"
#include "crypto/random.h"
namespace gcm {
namespace {
EntryVectorType;
const size_t kAuthSecretBytes = …;
std::string DatabaseKey(const std::string& app_id,
const std::string& authorized_entity) { … }
}
enum class GCMKeyStore::State { … };
GCMKeyStore::GCMKeyStore(
const base::FilePath& key_store_path,
const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
: … { … }
GCMKeyStore::~GCMKeyStore() = default;
void GCMKeyStore::GetKeys(const std::string& app_id,
const std::string& authorized_entity,
bool fallback_to_empty_authorized_entity,
KeysCallback callback) { … }
void GCMKeyStore::GetKeysAfterInitialize(
const std::string& app_id,
const std::string& authorized_entity,
bool fallback_to_empty_authorized_entity,
KeysCallback callback) { … }
void GCMKeyStore::CreateKeys(const std::string& app_id,
const std::string& authorized_entity,
KeysCallback callback) { … }
void GCMKeyStore::CreateKeysAfterInitialize(
const std::string& app_id,
const std::string& authorized_entity,
KeysCallback callback) { … }
void GCMKeyStore::DidStoreKeys(std::unique_ptr<crypto::ECPrivateKey> pair,
const std::string& auth_secret,
KeysCallback callback,
bool success) { … }
void GCMKeyStore::RemoveKeys(const std::string& app_id,
const std::string& authorized_entity,
base::OnceClosure callback) { … }
void GCMKeyStore::RemoveKeysAfterInitialize(
const std::string& app_id,
const std::string& authorized_entity,
base::OnceClosure callback) { … }
void GCMKeyStore::DidRemoveKeys(base::OnceClosure callback, bool success) { … }
void GCMKeyStore::DidUpgradeDatabase(bool success) { … }
void GCMKeyStore::LazyInitialize(base::OnceClosure done_closure) { … }
void GCMKeyStore::DidInitialize(leveldb_proto::Enums::InitStatus status) { … }
void GCMKeyStore::UpgradeDatabase(
std::unique_ptr<std::vector<EncryptionData>> entries) { … }
void GCMKeyStore::DidLoadKeys(
bool success,
std::unique_ptr<std::vector<EncryptionData>> entries) { … }
bool GCMKeyStore::DecryptPrivateKey(const std::string& to_decrypt,
std::string* decrypted) { … }
}