65 lines
2.7 KiB
C++
65 lines
2.7 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2016 Google LLC.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Utilities for manipulating the ClientIdentification proto.
|
|
// ClientIdentification.client_info() contains a sequence of
|
|
// arbitrary name-value pairs; this code consolidates the
|
|
// accessors for them in one place.
|
|
#ifndef COMMON_CLIENT_ID_UTIL_H_
|
|
#define COMMON_CLIENT_ID_UTIL_H_
|
|
|
|
#include "absl/strings/string_view.h"
|
|
#include "common/status.h"
|
|
#include "protos/public/client_identification.pb.h"
|
|
|
|
namespace widevine {
|
|
|
|
// Append the given name/value pair to client_id->client_info(). Does not
|
|
// check for duplicates.
|
|
void AddClientInfo(ClientIdentification* client_id, absl::string_view name,
|
|
absl::string_view value);
|
|
|
|
// Append the given name/value pair to client_id->client_info(). If the
|
|
// given name already had a value, replaces it and returns true.
|
|
bool SetClientInfo(ClientIdentification* client_id, absl::string_view name,
|
|
absl::string_view value);
|
|
|
|
// Return the value from client_id.client_info() matching the given name,
|
|
// or the empty std::string if not found.
|
|
std::string GetClientInfo(const ClientIdentification& client_id,
|
|
absl::string_view name);
|
|
|
|
// Return the value from client_id.client_info() matching the given name,
|
|
// or the given default value if not found.
|
|
std::string GetClientInfo(const ClientIdentification& client_id,
|
|
absl::string_view name,
|
|
const std::string& default_value);
|
|
|
|
// Decrypts the encrypted client identification in |encrypted_client_id| into
|
|
// |client_id| using the private key for the service certificate which was
|
|
// used to encrypt the information.
|
|
// |client_id| is owned by caller.
|
|
// Returns Status::OK, if successful, else an error.
|
|
Status DecryptEncryptedClientIdentification(
|
|
const EncryptedClientIdentification& encrypted_client_id,
|
|
ClientIdentification* client_id);
|
|
|
|
// Decrypts the encrypted client identification in |encrypted_client_id| into
|
|
// |client_id| using |privacy_key|.
|
|
// |client_id| is owned by caller.
|
|
// Returns Status::OK, if successful, else an error.
|
|
Status DecryptEncryptedClientIdentification(
|
|
const EncryptedClientIdentification& encrypted_client_id,
|
|
const std::string& privacy_key, ClientIdentification* client_id);
|
|
|
|
uint32_t GetSystemId(const ClientIdentification& client_id);
|
|
|
|
} // namespace widevine
|
|
|
|
#endif // COMMON_CLIENT_ID_UTIL_H_
|