#include "components/gcm_driver/crypto/gcm_message_cryptographer.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <string>
#include <string_view>
#include "base/containers/span.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/numerics/byte_conversions.h"
#include "base/numerics/ostream_operators.h"
#include "base/numerics/safe_conversions.h"
#include "base/numerics/safe_math.h"
#include "base/strings/strcat.h"
#include "crypto/hkdf.h"
#include "third_party/boringssl/src/include/openssl/aead.h"
namespace gcm {
namespace {
const uint64_t kNonceSize = …;
const size_t kDefaultRecordSize = …;
const size_t kContentEncryptionKeySize = …;
EVP_AEAD_CTX_TransformFunction;
class WebPushEncryptionDraft03
: public GCMMessageCryptographer::EncryptionScheme { … };
class WebPushEncryptionDraft08
: public GCMMessageCryptographer::EncryptionScheme { … };
}
const size_t GCMMessageCryptographer::kAuthenticationTagBytes = …;
const size_t GCMMessageCryptographer::kSaltSize = …;
GCMMessageCryptographer::GCMMessageCryptographer(Version version) { … }
GCMMessageCryptographer::~GCMMessageCryptographer() = default;
bool GCMMessageCryptographer::Encrypt(std::string_view recipient_public_key,
std::string_view sender_public_key,
std::string_view ecdh_shared_secret,
std::string_view auth_secret,
std::string_view salt,
std::string_view plaintext,
size_t* record_size,
std::string* ciphertext) const { … }
bool GCMMessageCryptographer::Decrypt(std::string_view recipient_public_key,
std::string_view sender_public_key,
std::string_view ecdh_shared_secret,
std::string_view auth_secret,
std::string_view salt,
std::string_view ciphertext,
size_t record_size,
std::string* plaintext) const { … }
bool GCMMessageCryptographer::TransformRecord(Direction direction,
std::string_view input,
std::string_view key,
std::string_view nonce,
std::string* output) const { … }
std::string GCMMessageCryptographer::DeriveContentEncryptionKey(
std::string_view recipient_public_key,
std::string_view sender_public_key,
std::string_view ecdh_shared_secret,
std::string_view salt) const { … }
std::string GCMMessageCryptographer::DeriveNonce(
std::string_view recipient_public_key,
std::string_view sender_public_key,
std::string_view ecdh_shared_secret,
std::string_view salt) const { … }
}