#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/cdm/json_web_key.h"
#include <stddef.h>
#include <memory>
#include <string_view>
#include <utility>
#include "base/base64url.h"
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/json/string_escape.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "media/base/content_decryption_module.h"
namespace media {
const char kKeysTag[] = …;
const char kKeyTypeTag[] = …;
const char kKeyTypeOct[] = …;
const char kKeyTag[] = …;
const char kKeyIdTag[] = …;
const char kKeyIdsTag[] = …;
const char kTypeTag[] = …;
const char kTemporarySession[] = …;
const char kPersistentLicenseSession[] = …;
static std::string ShortenTo64Characters(const std::string& input) { … }
static base::Value::Dict CreateJSONDictionary(const uint8_t* key,
int key_length,
const uint8_t* key_id,
int key_id_length) { … }
std::string GenerateJWKSet(const uint8_t* key,
int key_length,
const uint8_t* key_id,
int key_id_length) { … }
std::string GenerateJWKSet(const KeyIdAndKeyPairs& keys,
CdmSessionType session_type) { … }
static bool ConvertJwkToKeyPair(const base::Value::Dict& jwk,
KeyIdAndKeyPair* jwk_key) { … }
bool ExtractKeysFromJWKSet(const std::string& jwk_set,
KeyIdAndKeyPairs* keys,
CdmSessionType* session_type) { … }
bool ExtractKeyIdsFromKeyIdsInitData(const std::string& input,
KeyIdList* key_ids,
std::string* error_message) { … }
void CreateLicenseRequest(const KeyIdList& key_ids,
CdmSessionType session_type,
std::vector<uint8_t>* license) { … }
base::Value::Dict MakeKeyIdsDictionary(const KeyIdList& key_ids) { … }
std::vector<uint8_t> SerializeDictionaryToVector(
const base::Value::Dict& dictionary) { … }
void CreateKeyIdsInitData(const KeyIdList& key_ids,
std::vector<uint8_t>* init_data) { … }
std::vector<uint8_t> CreateLicenseReleaseMessage(const KeyIdList& key_ids) { … }
bool ExtractFirstKeyIdFromLicenseRequest(const std::vector<uint8_t>& license,
std::vector<uint8_t>* first_key) { … }
}